169 lines
5.9 KiB
YAML
169 lines
5.9 KiB
YAML
services:
|
||
service:
|
||
build:
|
||
context: .
|
||
target: development
|
||
ports:
|
||
- "8080:8080"
|
||
working_dir: &PROJECT_ROOT_DIR /app
|
||
# linux permissions / vscode support: we must explicitly run as the development user
|
||
user: development
|
||
volumes:
|
||
# mount working directory
|
||
# https://code.visualstudio.com/docs/remote/containers-advanced#_update-the-mount-consistency-to-delegated-for-macos
|
||
# https://docs.docker.com/docker-for-mac/osxfs-caching/#delegated
|
||
# the container’s view is authoritative (permit delays before updates on the container appear in the host)
|
||
- .:/app:delegated
|
||
|
||
# mount cached go pkg downloads
|
||
- go-pkg:/go/pkg
|
||
|
||
# speed up tmp dirs in working directory by using separate volumes (not the host's filesystem)
|
||
- workdir-api-tmp:/app/api/tmp
|
||
- workdir-bin:/app/bin
|
||
- workdir-tmp:/app/tmp
|
||
|
||
# mount cached vscode container extensions
|
||
# https://code.visualstudio.com/docs/remote/containers-advanced#_avoiding-extension-reinstalls-on-container-rebuild
|
||
- vscode-extensions:/home/development/.vscode-server/extensions
|
||
- vscode-extensions-insiders:/home/development/.vscode-server-insiders/extensions
|
||
|
||
# https://code.visualstudio.com/remote/advancedcontainers/persist-bash-history
|
||
# keep user development .bash_history between container restarts
|
||
- bash-history:/home/development/commandhistory
|
||
|
||
depends_on:
|
||
- postgres
|
||
- integresql
|
||
environment:
|
||
# required: env for main working database, service
|
||
# default for sql-migrate (target development) and psql cli tool
|
||
PGDATABASE: &PGDATABASE "development"
|
||
PGUSER: &PGUSER "dbuser"
|
||
PGPASSWORD: &PGPASSWORD "dbpass"
|
||
PGHOST: &PGHOST "postgres"
|
||
PGPORT: &PGPORT "5432"
|
||
PGSSLMODE: &PGSSLMODE "disable"
|
||
|
||
# optional: env for sql-boiler (ability to generate models out of a "spec" database)
|
||
# sql-boiler should operate on a "spec" database only
|
||
PSQL_DBNAME: "spec"
|
||
PSQL_USER: *PGUSER
|
||
PSQL_PASS: *PGPASSWORD
|
||
PSQL_HOST: *PGHOST
|
||
PSQL_PORT: *PGPORT
|
||
PSQL_SSLMODE: *PGSSLMODE
|
||
|
||
# optional: project root directory, used for relative path resolution (e.g. fixtures)
|
||
PROJECT_ROOT_DIR: *PROJECT_ROOT_DIR
|
||
|
||
# optional: env for integresql client testing
|
||
# INTEGRESQL_CLIENT_BASE_URL: "http://integresql:5000/api"
|
||
|
||
# optional: enable pretty print of log output
|
||
# intended use is for development and debugging purposes only
|
||
# not recommended to enable on production systems due to performance penalty and loss of parsing ability
|
||
SERVER_LOGGER_PRETTY_PRINT_CONSOLE: "true"
|
||
|
||
# optional: static management secret to easily call http://localhost:8080/-/healthy?mgmt-secret=mgmtpass
|
||
SERVER_MANAGEMENT_SECRET: "mgmtpass"
|
||
|
||
# path to the changie config
|
||
CHANGIE_CONFIG_PATH: "/app/.changie-go-starter.yaml"
|
||
|
||
# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
|
||
cap_add:
|
||
- SYS_PTRACE
|
||
security_opt:
|
||
- seccomp:unconfined
|
||
|
||
# Overrides default command so things don't shut down after the process ends.
|
||
command:
|
||
- /bin/sh
|
||
- -c
|
||
- |
|
||
sudo chown -R development:development /app/api/tmp
|
||
sudo chown -R development:development /app/bin
|
||
sudo chown -R development:development /app/tmp
|
||
chmod +x /app/rksh
|
||
git config --global --add safe.directory /app
|
||
while sleep 1000; do :; done
|
||
|
||
postgres:
|
||
image: postgres:17.4-alpine # should be the same version as used in .drone.yml, .github/workflows, Dockerfile and live
|
||
# ATTENTION
|
||
# fsync=off, synchronous_commit=off and full_page_writes=off
|
||
# gives us a major speed up during local development and testing (~30%),
|
||
# however you should NEVER use these settings in PRODUCTION unless
|
||
# you want to have CORRUPTED data.
|
||
# DO NOT COPY/PASTE THIS BLINDLY.
|
||
# YOU HAVE BEEN WARNED.
|
||
# Apply some performance improvements to pg as these guarantees are not needed while running locally
|
||
command: "postgres -c 'shared_buffers=128MB' -c 'fsync=off' -c 'synchronous_commit=off' -c 'full_page_writes=off' -c 'max_connections=100' -c 'client_min_messages=warning'"
|
||
expose:
|
||
- "5432"
|
||
ports:
|
||
- "5432:5432"
|
||
environment:
|
||
POSTGRES_DB: *PGDATABASE
|
||
POSTGRES_USER: *PGUSER
|
||
POSTGRES_PASSWORD: *PGPASSWORD
|
||
volumes:
|
||
- pgvolume:/var/lib/postgresql/data
|
||
|
||
integresql:
|
||
image: ghcr.io/allaboutapps/integresql:v1.1.0
|
||
expose:
|
||
- "5000"
|
||
depends_on:
|
||
- postgres
|
||
environment:
|
||
PGHOST: *PGHOST
|
||
PGUSER: *PGUSER
|
||
PGPASSWORD: *PGPASSWORD
|
||
|
||
mailhog:
|
||
image: mailhog/mailhog
|
||
expose:
|
||
- "1025"
|
||
ports:
|
||
- "8025:8025"
|
||
|
||
swaggerui:
|
||
image: swaggerapi/swagger-ui:v3.46.0
|
||
environment:
|
||
SWAGGER_JSON: "/api/swagger.yml"
|
||
volumes:
|
||
# mount our local main swagger.yml file (refresh your browser to see changes)
|
||
- ./api:/api:ro,consistent
|
||
# mount overwritten translator.js (intercept requests port 8081 to our local service on port 8080)
|
||
- ./api/config/swagger-ui-local-translator.js:/usr/share/nginx/configurator/translator.js:ro,delegated
|
||
|
||
swaggerui-browser-sync:
|
||
image: allaboutapps/browser-sync:v2.26.14
|
||
command: start --proxy 'swaggerui:8080' --port 8081 --files "/api/*.yml"
|
||
volumes:
|
||
- ./api:/api:ro,consistent
|
||
ports:
|
||
- "8081:8081"
|
||
|
||
volumes:
|
||
# postgresql: declare a named volume to persist DB data
|
||
pgvolume:
|
||
|
||
# go: go mod cached downloads
|
||
go-pkg:
|
||
|
||
# tmp dirs in workdir
|
||
workdir-api-tmp:
|
||
workdir-bin:
|
||
workdir-tmp:
|
||
|
||
# vscode: Avoiding extension reinstalls on container rebuild
|
||
# https://code.visualstudio.com/docs/remote/containers-advanced#_avoiding-extension-reinstalls-on-container-rebuild
|
||
vscode-extensions:
|
||
vscode-extensions-insiders:
|
||
|
||
# https://code.visualstudio.com/remote/advancedcontainers/persist-bash-history
|
||
bash-history:
|