I'm using docker multistage build and am trying to add a live reload feature to my dockerized go application. I have an entrypoint.sh with its own configurations in the second image.
Now, the problem is that the command CMD ["air", "-c", ".air.toml"]
from the first image gets overwritten by the ENTRYPOINT ["/entrypoint.sh"]
scripts from the second image, so it is only the ENTRYPOINT
that is started and CMD
doesn't run.
I can't combine them into the only command like so
ENTRYPOINT ["/entrypoint.sh", "air", "-c", ".air.toml"]
because the second Image doesn't have Golang language installed with the respective libraries.
Is it possible somehow to run CMD
and ENTRYPOINT
side by side? Thank you.
Dockerfile
FROM golang:1.17.2
COPY . /go/src/sample
WORKDIR /go/src/sample
RUN go install github.com/go-delve/delve/cmd/dlv@latest
RUN go install github.com/cosmtrek/air@latest
CMD ["air", "-c", ".air.toml"]
FROM eclipse-temurin:17-focal
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
docker-compose.yml
version: '3'
services:
go:
build:
context: ./backend
dockerfile: Dockerfile
volumes:
- ./backend:/go/src/backend
working_dir: /go/src/backend
ports:
- 8080:8080