- Go >= 1.19.2
# build cross platform
$ CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app
# Database
$ docker run --name mysql --privileged=true \
-e MYSQL_ROOT_PASSWORD="1234" \
-e MYSQL_USER="food_delivery" \
-e MYSQL_PASSWORD="1234" \
-e MYSQL_DATABASE="food_delivery" \
-p 3306:3306 bitnami/mysql:5.7
#docker build
$ docker build -t food-delivery-image
# create a network
$ docker network create fd-delivery
# docker network connect
$ docker network connect fd-delivery mysql
# run
$ docker run -d --name food-delivery \
-e DBConnectionStr="food_delivery:1234@tcp(mysql:3306)/food_delivery?charset=utf8mb4&parseTime=True&loc=Local" \
--network=fd-delivery \
-p 3001:8080 \
food-delivery-app
≈Install 🐳🐳 DOCKER 🐳🐳 Engine on Ubuntu≈
Reference
$ sudo apt-get update
$ sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
$ sudo mkdir -p /etc/apt/keyrings
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
$ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
$ docker run -d -p 80:80 -p 443:443 \
--network=fd-delivery --name nginx-proxy \
-e ENABLE_IPV6=true \
--privileged=true \
-v ~/nginx/vhost.d:/etc/nginx/vhost.d \
-v ~/nginx-certs:/etc/nginx/certs:ro \
-v ~/nginx-conf:/etc/nginx/conf.d \
-v ~/nginx-logs:/var/log/nginx \
-v /usr/share/nginx/html \
-v /var/run/docker.sock:/tmp/docker.socker:ro \
--label nginx_proxy jwilder/nginx-proxy
$ docker run -d --network=fd-delivery \
-v ~/nginx/vhost.d:/etc/nginx/vhost.d \
-v ~/nginx-certs:/etc/nginx/certs:rw \
-v /var/run/docker.sock:/tmp/docker.socker:ro \
--volumes-from nginx-proxy \
--privileged=true \
jrcs/letsencrypt-nginx-proxy-companion
👤 Chien Anbs
- Github: @hvchien216