Skip to content

Instantly share code, notes, and snippets.

@dudo
Last active August 28, 2024 21:32
Show Gist options
  • Save dudo/96cd32821e78385c88560b50b7a12a4d to your computer and use it in GitHub Desktop.
Save dudo/96cd32821e78385c88560b50b7a12a4d to your computer and use it in GitHub Desktop.
Local development with docker
# Update appropriately to find your languages long term support release, or latest.
FROM node:20
# Embrace linux standards.
WORKDIR /usr/src/app
# Embrace layers. Update to appropriate language/framework file(s).
ADD package*.json ./
# Grab the rest of the local files.
ADD . ./
services:
go: &go
env_file:
- path: .env
required: false
tty: true
stdin_open: true
build:
context: .
entrypoint: go
command: help
volumes:
- .:/usr/src/app:delegated
- gomod:/go/pkg/mod:cached
app:
<<: *go
command: run ./cmd/app/main.go
ports:
- ${PORT}:${PORT}
volumes:
gomod: {}
services:
mvn: &mvn
env_file:
- path: .env
required: false
tty: true
stdin_open: true
build:
context: .
entrypoint: mvn
command: --help
volumes:
- .:/usr/src/app:delegated
- jars:/root/.m2/repository:cached
app:
<<: *mvn
command: spring-boot:run
ports:
- ${PORT}:${PORT}
volumes:
jars: {}
services:
npm: &npm
env_file:
- path: .env
required: false
tty: true
stdin_open: true
build:
context: .
entrypoint: npm
command: help
volumes:
- .:/usr/src/app:delegated
- node_modules:/node_modules:cached
npx: &npx
<<: *npm
entrypoint: npx
command: -h
app:
<<: *npm
command: run start
ports:
- ${PORT}:${PORT}
volumes:
node_modules: {}
services:
pip: &pip
env_file:
- path: .env
required: false
tty: true
stdin_open: true
build:
context: .
entrypoint: pip
command: --help
volumes:
- .:/usr/src/app:delegated
- deps:/usr/local/lib/python3.8/site-packages:cached
pytest:
<<: *pip
entrypoint: pytest
command: --help
environment:
PYTHON_ENV: test
app:
<<: *pip
entrypoint: python
command: main.py
ports:
- ${PORT}:${PORT}
volumes:
deps: {}
services:
bundle: &bundle
env_file:
- path: .env
required: false
tty: true
stdin_open: true
build:
context: .
entrypoint: bundle
command: help
volumes:
- .:/usr/src/app:delegated
- bundle:/usr/local/bundle:cached
rspec:
<<: *bundle
entrypoint: bundle exec rspec
command: --help
environment:
RAILS_ENV: test
app:
<<: *bundle
command: exec rails server
ports:
- ${PORT}:${PORT}
volumes:
bundle: {}
@dudo
Copy link
Author

dudo commented Aug 28, 2024

With the recent addition of watch, we no longer add local files to the volume, and instead use

develop:
  watch:

then start up our applications with docker compose watch, which kicks off the services as daemons, but keeps the terminal connected to show file changes and restarts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment