Docker image for golang development with hot-reload
This image allows to run golang inside container with possibility to:
- Due to some specifics which were needed,
GOFLAGS
is set to'-mod=vendor'
. This could be overwritten usingdocker-compose
file WORKDIR
is set to/app
so watcher expects source code to be located under workdir. (Just map your code to/app
usingdocker-compose
)- Signalling - when running in debug mode, -9 (kill) is send to debugger and application. When running in
GO_NO_DEBUG=true
mode, TERM signal is sent to application - Files watching - right now only files with extension
go
are monitored. Next versions would probably include some ENV for this - Delve api version 2 is used
The following env variables are available:
PACKAGE_DIR
- package where the main file located if not in root. Example:./cmd/run
. Defaults to.
GO_NO_DEBUG
- set it to anything except empty value to disable debugging, leaving only hot-reload on code changesGOMON_DIED_CHECK_INTERVAL
- (in seconds, default: 2s) monitor will check if APP is alive with set intervalGOMON_IGNORE
- extended regex to exclude files being watchedGO_DEBUG_STARTUP_RETRIES
- max amount of 10-sec sleep iterations to give debugger time to properly set up, while running withoutGO_NO_DEBUG
. Defaults to6
Port 40000 is exposed for delve debugging
version: '2.1'
services:
go-dev:
image: gomon-docker:1.13
environment:
GO_NO_DEBUG: "true"
volumes:
- .:/app:delegated
ports:
- 9080 # your application exposed port
network_mode: bridge
restart: always
version: '2.1'
services:
go-dev:
image: gomon-docker:1.13
volumes:
- .:/app:delegated
ports:
- 40000:40000 # this is Delve debugging port
- 9080 # your application exposed port
network_mode: bridge
restart: always