Skip to content

Instantly share code, notes, and snippets.

@dudo
Last active February 14, 2024 18:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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: .env
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: .env
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: .env
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: .env
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: .env
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 Feb 14, 2024

Use run to execute the services ad hoc.

This alias makes that easy. The doctor will see you now.

alias dr='docker compose run --rm '

Then run the commands you know and love, prefixed with dr.

dr npm update
dr bundle exec rails console
dr go mod tidy
# dr [service] whatevs

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