Skip to content

Instantly share code, notes, and snippets.

@spalt08
Created September 4, 2019 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spalt08/07f8ba292852a054574044b3c1d00726 to your computer and use it in GitHub Desktop.
Save spalt08/07f8ba292852a054574044b3c1d00726 to your computer and use it in GitHub Desktop.
Go live-reload snippet
version: '3.7'
services:
# Production container. Builds in release mode and run. Project will be restarted on every abort.
production:
hostname: my-app-production
restart: unless-stopped
build:
context: .
dockerfile: Dockerfile
target: base
environment:
GIN_MODE: "release" # Example ENV variable
SERVING_PORT: "*:8080" # Example ENV variable
volumes:
- .:/home/my-app
working_dir: /home/my-app
ports:
- "8080:8080" # Opened ports
command: bash -c "go mod download && go build -o /bin/my-app . && /bin/my-app"
# Development container. Runs in debug mode and live-reloading on every source file update.
development:
hostname: my-app-development
restart: unless-stopped
build:
context: .
dockerfile: Dockerfile
target: dev
environment:
DEBUG: "true" # Example ENV variable
SERVING_PORT: ":8081" # Example ENV variable
volumes:
- ./home/my-app
working_dir: /home/my-app
ports:
- "8081:8081"
command: bash -c "go mod download && make serve"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment