Skip to content

Instantly share code, notes, and snippets.

@charlesxsh
Created July 12, 2018 22:04
Show Gist options
  • Save charlesxsh/779b2b9d8813cf451c6c35481e3940fe to your computer and use it in GitHub Desktop.
Save charlesxsh/779b2b9d8813cf451c6c35481e3940fe to your computer and use it in GitHub Desktop.
Example of dockerize your developing environment
version: '2'
services:
db:
image: postgres
ports:
- 5432:5432
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
# You definitly need some tools to visualize/edit/debug your database right?
yourprojectname-pgadmin:
image: dpage/pgadmin4
ports:
- 8888:80
environment:
- PGADMIN_DEFAULT_EMAIL=user@domain.com
- PGADMIN_DEFAULT_PASSWORD=SuperSecret
links:
# SERVICE:ALIAS
# Link your db service to database domain, so that in pgadmin you can use postgres://database:5432... to access your db
- "db:database"
# your go enviroment
workspace:
image: golang:1.10
# why we need a container_name here? just easy for you to attach
container_name: workspace
ports:
- 8080:80
volumes:
# attach folder of your project in local filesystem to this container
- ".:{your path}"
environment:
- PGURL=postgres://postgres:postgres@database:5432/postgres?sslmode=disable
- PORT=80
# change the path to your project root here so that once you attach this container, you will be in the project root
command: bash -c "cd /go/src/... && bash"
stdin_open: true
tty: true
links:
# so that this container can access your database service using postgres://database...
- "db:database"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment