Last active
August 28, 2024 21:32
-
-
Save dudo/96cd32821e78385c88560b50b7a12a4d to your computer and use it in GitHub Desktop.
Local development with docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 . ./ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: {} |
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
Use run to execute the services ad hoc.
This alias makes that easy. The doctor will see you now.
Then run the commands you know and love, prefixed with
dr
.