Skip to content

Commit

Permalink
Improve local docker startup time (#1401)
Browse files Browse the repository at this point in the history
* add volume to cache dependancies

* docker install delve

* volume for go build cache
  • Loading branch information
SimoneDutto authored Oct 21, 2024
1 parent 70bbc79 commit 4e7bd9b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
tmp
16 changes: 9 additions & 7 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,21 @@ services:
extends:
file: docker-compose.common.yaml
service: jimm-base
image: cosmtrek/air:latest
build:
context: .
dockerfile: ./local/Dockerfile
profiles: ["dev"]
# working_dir value has to be the same of mapped volume
hostname: jimm.localhost
working_dir: /jimm
container_name: jimm
entrypoint:
- bash
- -c
- >-
go install github.com/go-delve/delve/cmd/dlv@latest
&& air
ports:
- 17070:80
- 2345:2345
volumes:
- ./:/jimm/
- go-modules:/go/pkg/mod # cache modules to improve startup
- go-cache:/root/.cache/go-build # cache build's artifacts to startup

db:
image: postgres
Expand Down Expand Up @@ -133,3 +131,7 @@ services:
interval: 5s
timeout: 10s
retries: 30

volumes:
go-modules:
go-cache:
6 changes: 6 additions & 0 deletions local/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Installing delve in the image to avoid running go install in running containers
FROM cosmtrek/air:latest

RUN go install github.com/go-delve/delve/cmd/dlv@latest

ENTRYPOINT [ "air" ]

0 comments on commit 4e7bd9b

Please sign in to comment.