18th July 2024


Earlier than diving into the method of working Go functions with Plesk, it’s important to make sure you have the required conditions in place. Right here’s an in depth breakdown of what you want:

Plesk Set up

To make use of Plesk, you will need to set up it in your server. Guarantee you could have the most recent model put in, or the model you propose to make use of. When you haven’t already put in Plesk, you could must observe the official set up information to your particular server and working system. There is no such thing as a want to fret in regards to the license, you will get a two-week trial license proper from the panel.

Server or Internet hosting Surroundings

It’s best to have entry to a server or internet hosting setting the place Plesk is put in. This setting would be the basis for internet hosting your Go software.
Additionally, it’s essential to know that Docker is offered just for Plesk directors.

Go Information

Whereas this information will stroll you thru the technical points of deploying Go functions, having a fundamental understanding of the Go programming language is useful. You need to be acquainted with ideas like bundle administration, constructing, and working Go functions.

With these conditions in place, you’ll be well-prepared to observe the steps on this information for working your Go software with Plesk. It’s important to make sure you have a dependable internet hosting setting (Plesk), in addition to a fundamental understanding of Go, to make the method smoother and extra environment friendly.

Getting ready Your Go Utility

Earlier than you possibly can deploy a Go software with Plesk, you’ll want to arrange your software for internet hosting. For demonstration functions, let’s create a easy HTTP software. Listed here are the steps to observe:

1. Create a listing for the undertaking:
mkdir go-http-sample
cd go-http-sample
2. Create the principle.go file within the go-http-sample listing:
bundle foremost

import (

func hey(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "hellon")

func foremost() {
http.HandleFunc("/", hey)
http.ListenAndServe(":8090", nil)

3. Check your software domestically:
#> go run foremost.go &        
#> curl localhost:8090/
4. Then let’s create a pattern Dockerfile:
FROM golang:1.20.10-alpine3.18 as builder

COPY go.mod go.sum ./
RUN go mod obtain
COPY . .
RUN CGO_ENABLED=zero GOOS=linux go construct -o ./http-server

FROM scratch

COPY --from=builder /app/http-server .
CMD ["/app/http-server"]

5. Check your docker picture:
#> docker run -itd -p 8090:8090 $(docker construct -q .)
#> curl localhost:8090/

Cool, so every little thing needs to be working as anticipated and we will now put together the Plesk management panel!

Setting Up Plesk 

I’m assuming you have already got a Plesk occasion. Then, it’s essential to set up a docker extension. You are able to do it simply through the extension catalog.  

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.