[Golang] Create Dockerfile for golang app

Containerizing the application is very popular nowadays and it makes the deployment so easy. This post will show how to create a Dockerfile for golang application. There are basically two steps in the Dockerfile: Build the golang program source code Containerize the golang app binary # Build source code FROM golang:1.18-alpine AS build WORKDIR /go/src/github.com/app COPY . . RUN go mod tidy RUN CGO_ENABLED=0 GOOS=linux go build -a -o main . # Containerize the binary FROM alpine COPY --from=build /go/src/github.com/app/main . EXPOSE 3500 CMD ["/main"] Exporting the port 3500 is because golang app listens to 3500. Here is just an example. ...

[Dokku] Command Cheatsheet

A quick reference guide for commonly used Dokku commands. 1. Create and list app # Create app dokku apps:create <app_name> # List app dokku apps:list 2. Set domains # Set app's domain dokku domains:set <app_name> app.example.com # Set global domain dokku domains:set-global example.com 3. Join app to a specific network # List all networks dokku network:list # Add an app to a specific network dokku network:set <app_name> initial-network <target_network> 4. Show the app’s configuration dokku config:show <app_name> 5. Manully restart an app dokku ps:rebuild <app_name> 6. Bind app container to all interface bind to all interfaces (0.0.0.0), so the container can be accessed by external request. However, the host port will be randomly assigned. ...

[Dokku] How to install Dokku with Portainer

We can easily figure out how to set up Dokku by following the instructions on Dokku website. But for me, I like to host services in docker container as it will bring a clearer structure when it comes to host multiple services in a single machine. In this post, I will assume that you already had some idea about what Dokku is. If not, you can find more information here. In the title, I also mentioned another tool called Portainer. Basically it is a management tool of docker container and kubernete cluster with UI. But it is actually much more than that. (I feel I am digging a bit hole while introducing more and more tools). ...

DigitalOcean Referral Badge
Sign up to get $200, 60-day account credit !