This might be a dumb question, but I'm new to using Docker-compose. While I like it ... but I have a lot of time to build. I have a project with several dependencies, and I have to explicitly rebuild the source every time I make changes. I'm calling right now docker-compose buildto rebuild the container, and then docker-compose up. The problem is this:
It rebuilds the entire container for every change I make for the source code (which takes a lot of time - fetching / etc). It slows me down a lot.
I really feel that I just need to run the command in the recovery container and then re-run the executable, for example:
docker-compose run web go build.
docker-compose run web ./app
ordocker-compose run web go build.
docker-compose restart
. This should work because I'm using a volume to share code between the host and the container. You will not need to reinstall all the dependencies. Should I just use the newly created executable? However, this does not reflect the built-in changes, and port forwarding seems to be interrupted.
For reference, here is my Docker file:
FROM golang:1.8
COPY . /go/src/github.com/codeblooded/test1
WORKDIR /go/src/github.com/codeblooded/test1
RUN echo $PATH
RUN go get -d -v ./...
RUN go install -v ./...
RUN go build -o test1 .
CMD ["test1"]
EXPOSE 3470
And my docker-compose.yml file:
version: '3'
services:
postgres:
image: postgres
volumes:
- ./db/data/psql:/var/lib/postgresql/data
- ./db/schema:/db/schema
redis:
image: redis
volumes:
- ./db/data/redis:/data
server:
build: .
command: test1
volumes:
- .:/go/src/github.com/codeblooded/test1
ports:
- "3470:3470"
depends_on:
- postgres
- redis
Is there something I am missing?
source
share