my goal is to work on a project using docker without having to constantly rebuild my whole project each time I modify a file a little bit:
The file bellow (not complete) has 2 state, an already updated version that I will call
Version_0 which looks like this :
<#modelInf> rdf:type ja:InfModel ;
# ja:content [ja:externalContent <file:/fuseki/ontologies/server_famille.ttl> ; ] ;
ja:reasoner [
ja:reasonerClass "openllet.jena.PelletReasonerFactory" ; ]
.
Once updated it works well, but then I decide to uncomment one line, this file I will call Version_1 :
<#modelInf> rdf:type ja:InfModel ;
ja:content [ja:externalContent <file:/fuseki/ontologies/server_famille.ttl> ; ] ;
ja:reasoner [
ja:reasonerClass "openllet.jena.PelletReasonerFactory" ; ]
.
The important part of my dockerfile looks like that :
FROM [...]
RUN mkdir -p /fuseki
RUN mkdir -p /fuseki/configuration/
WORKDIR /fuseki
COPY server/configuration/db_tdb.ttl configuration
I also run a docker-compose file [Edited]
version: "3"
services:
jena-fuseki-server:
hostname: jena-fuseki
build:
context: .
dockerfile: server.Dockerfile
restart: always
ports:
- 3030:3030
environment:
- ADMIN_PASSWORD=admin
- FUSEKI_DATASET_1=ds
command: cat /fuseki/configuration/db_tdb.ttl
The issue seems to be that the first time I run $docker-compose up --build
it works well and copy Version_0 right, after modification, I rerun $docker-compose up --build
and I expect Version_1 to be the file copied. what happens is that, after verification navigating my image thanks to docker exec -it [name] bash
and executing cat db_tdb.ttl
, it still shows me Version_0. Testing my app confirm me that Version_0 is the one running.
[Edited] The cat
command I added shows me that Version_0 is the one copied aswell
What have you tried ?
- The command
docker-compose build --no-cache
followed bydocker-compose up
result: didn't work and doesn't accomplish what I want. - The command
docker system prune -a
followed bydocker-compose up --build
result: it did work but doesn't accomplish what I want. - I also tried to target the configuration folder instead of the file itself
result: no noticeable changes. - Adding a
RUN rm -f configuration
result: no noticeable changes - [Edited] Run :
docker-compose up --build --force-recreate
result : no noticeable changes
Honorable mentions
- During my project, I did not always have this issue.
- When I use
docker-compose up --build
it uses the cache except for the modified file yet still doesn't work
Since it is a big project, I can't resolve myself to run docker system prune -a
or using --no-cache
as it would result in a HUGE lost of time.
I feel like it worked at some point but I can't understand the reason nor give it consistancy.
Thanks you.
CodePudding user response:
Try doing docker-compose down
followed by docker-compose up --build
.
It seems that removing the container first fixes some hidden cache problems.