Skip to content

feat: add Dockerfile and docker-compose.yml for containerized application setup#334

Open
JessUWE wants to merge 4 commits intomainfrom
feature/containerize-docke
Open

feat: add Dockerfile and docker-compose.yml for containerized application setup#334
JessUWE wants to merge 4 commits intomainfrom
feature/containerize-docke

Conversation

@JessUWE
Copy link
Copy Markdown
Contributor

@JessUWE JessUWE commented Apr 1, 2026

Summary
This PR introduces Docker containerization support to the SACRO-Viewer project, enabling consistent development and production environments.

Files Changed

  • .dockerignore - Added/updated to exclude unnecessary files like node_modules, git files, and test artifacts from the Docker build, keeping the image smaller and builds faster.

  • Dockerfile - Created a new multi-stage Docker setup. The first stage uses Node.js to build frontend assets (Vite, Tailwind, PostCSS). The second stage uses Python to run the Django app with Uvicorn.

  • docker-compose.yml - Created a new service configuration that maps port 8000, mounts volumes for data and outputs, loads environment from .env, and includes health checks to monitor the app.

Impact

  • Standardizes local and production environments via Docker
  • Reduces image size and improves build times
  • No changes to application runtime behavior
  • Local development now runs via docker-compose

How to test

  • Run: docker-compose up --build
  • Verify the app starts successfully and is accessible at the expected port

@JessUWE JessUWE linked an issue Apr 1, 2026 that may be closed by this pull request
@JessUWE JessUWE requested review from jim-smith and rpreen April 1, 2026 10:09
… steps for macOS, Windows, and Linux, and commands for running, checking, and managing the Docker container.
@jim-smith
Copy link
Copy Markdown
Collaborator

@JessUWE just tested this by:

  1. pulling the branch from GitHub, switching into it and pulling to get latest version
  2. opening the docker app on my Mac book (next step wouldn't;t work otherwise)
  3. docker-compose build --no-cache succeeded
  4. docker-compose up -d
  5. open localhost:8000 in my browser.

This all worked, BUT after selecting either researcher or output checker I then get the version which opens some data directly already - I.e does not allow me to chose what directory ot open.

Question 1 this the desired behaviour ? I.e. is it a container thing and the folder has to be specified and mapped in the Dockerfile?

If so, then the researcher option doesn't make sense:

  • you can add a file but when I added a png file it didn't display properly

  • if you try to edit the type of a file, or delete files you get a load of errors

  • after doing that, when I went in aa an output checker I just got a screen full or error - maybe because trying ot be a researcher had damaged outputs.json

Question 2: Maybe we need to be clear about the use-case? I.e. maybe having it run in a docker container only makes sense for output checking?

@JessUWE
Copy link
Copy Markdown
Contributor Author

JessUWE commented Apr 8, 2026

@JessUWE just tested this by:

  1. pulling the branch from GitHub, switching into it and pulling to get latest version
  2. opening the docker app on my Mac book (next step wouldn't;t work otherwise)
  3. docker-compose build --no-cache succeeded
  4. docker-compose up -d
  5. open localhost:8000 in my browser.

This all worked, BUT after selecting either researcher or output checker I then get the version which opens some data directly already - I.e does not allow me to chose what directory ot open.

Question 1 this the desired behaviour ? I.e. is it a container thing and the folder has to be specified and mapped in the Dockerfile?

If so, then the researcher option doesn't make sense:

  • you can add a file but when I added a png file it didn't display properly
  • if you try to edit the type of a file, or delete files you get a load of errors
  • after doing that, when I went in aa an output checker I just got a screen full or error - maybe because trying ot be a researcher had damaged outputs.json

Question 2: Maybe we need to be clear about the use-case? I.e. maybe having it run in a docker container only makes sense for output checking?

@jim-smith It’s not clear what you mean by “next step didn’t work” for step 2. Is your Docker status showing as running?

I’m not seeing these issues on my end. Also, just to clarify- on the current branch, the SACRO Viewer feature for the folder picker hasn’t been merged yet.

As we agreed previously, this should be fully tested before opening a PR.

When you ran it and checked your docker application did it show something like the below;
Screenshot 2026-04-08 at 11 50 17

Screenshot 2026-04-08 at 12 18 57

Question 1: Yes, this is expected Docker behaviour. The data is baked into the container at build time (via COPY data ./data in the Dockerfile), so there's no folder picker in the Docker version, that's a feature on a different branch. The Docker version is intentionally pre-loaded with the sample data

Question 2: The researcher workflow (adding, renaming, deleting files) does work, we've verified this on our end. The errors you're seeing are likely because the sample outputs.json got corrupted during your session which has nothing to do with docker. Could you try:

  • Running docker-compose down then docker-compose up -d to get a fresh container with clean data
  • Then testing the researcher workflow again from scratch

@jim-smith
Copy link
Copy Markdown
Collaborator

@JessUWE just tested this by:

  1. pulling the branch from GitHub, switching into it and pulling to get latest version
  2. opening the docker app on my Mac book (next step wouldn't;t work otherwise)
  3. docker-compose build --no-cache succeeded
  4. docker-compose up -d
  5. open localhost:8000 in my browser.

This all worked, BUT after selecting either researcher or output checker I then get the version which opens some data directly already - I.e does not allow me to chose what directory ot open.
Question 1 this the desired behaviour ? I.e. is it a container thing and the folder has to be specified and mapped in the Dockerfile?
If so, then the researcher option doesn't make sense:

  • you can add a file but when I added a png file it didn't display properly
  • if you try to edit the type of a file, or delete files you get a load of errors
  • after doing that, when I went in aa an output checker I just got a screen full or error - maybe because trying ot be a researcher had damaged outputs.json

Question 2: Maybe we need to be clear about the use-case? I.e. maybe having it run in a docker container only makes sense for output checking?

@jim-smith It’s not clear what you mean by “next step didn’t work” for step 2. Is your Docker status showing as running?

I’m not seeing these issues on my end. Also, just to clarify- on the current branch, the SACRO Viewer feature for the folder picker hasn’t been merged yet.

As we agreed previously, this should be fully tested before opening a PR.

When you ran it and checked your docker application did it show something like the below; Screenshot 2026-04-08 at 11 50 17

Screenshot 2026-04-08 at 12 18 57 **Question 1:** Yes, this is expected Docker behaviour. The data is baked into the container at build time (via COPY data ./data in the Dockerfile), so there's no folder picker in the Docker version, that's a feature on a different branch. The Docker version is intentionally pre-loaded with the sample data

Question 2: The researcher workflow (adding, renaming, deleting files) does work, we've verified this on our end. The errors you're seeing are likely because the sample outputs.json got corrupted during your session which has nothing to do with docker. Could you try:

  • Running docker-compose down then docker-compose up -d to get a fresh container with clean data
  • Then testing the researcher workflow again from scratch

Hi @JessUWE will test this later.
re Question 1:
reQuestion 2 is the data directory mounted r/w? if not how/when does the modified version of outputs.json get written back to somewhere outside the file space specific to the instance of the docker container that the researcher is interacting with??

@JessUWE
Copy link
Copy Markdown
Contributor Author

JessUWE commented Apr 9, 2026

@JessUWE just tested this by:

  1. pulling the branch from GitHub, switching into it and pulling to get latest version
  2. opening the docker app on my Mac book (next step wouldn't;t work otherwise)
  3. docker-compose build --no-cache succeeded
  4. docker-compose up -d
  5. open localhost:8000 in my browser.

This all worked, BUT after selecting either researcher or output checker I then get the version which opens some data directly already - I.e does not allow me to chose what directory ot open.
Question 1 this the desired behaviour ? I.e. is it a container thing and the folder has to be specified and mapped in the Dockerfile?
If so, then the researcher option doesn't make sense:

  • you can add a file but when I added a png file it didn't display properly
  • if you try to edit the type of a file, or delete files you get a load of errors
  • after doing that, when I went in aa an output checker I just got a screen full or error - maybe because trying ot be a researcher had damaged outputs.json

Question 2: Maybe we need to be clear about the use-case? I.e. maybe having it run in a docker container only makes sense for output checking?

@jim-smith It’s not clear what you mean by “next step didn’t work” for step 2. Is your Docker status showing as running?
I’m not seeing these issues on my end. Also, just to clarify- on the current branch, the SACRO Viewer feature for the folder picker hasn’t been merged yet.
As we agreed previously, this should be fully tested before opening a PR.
When you ran it and checked your docker application did it show something like the below; Screenshot 2026-04-08 at 11 50 17
Screenshot 2026-04-08 at 12 18 57
Question 1: Yes, this is expected Docker behaviour. The data is baked into the container at build time (via COPY data ./data in the Dockerfile), so there's no folder picker in the Docker version, that's a feature on a different branch. The Docker version is intentionally pre-loaded with the sample data
Question 2: The researcher workflow (adding, renaming, deleting files) does work, we've verified this on our end. The errors you're seeing are likely because the sample outputs.json got corrupted during your session which has nothing to do with docker. Could you try:

  • Running docker-compose down then docker-compose up -d to get a fresh container with clean data
  • Then testing the researcher workflow again from scratch

Hi @JessUWE will test this later. re Question 1: reQuestion 2 is the data directory mounted r/w? if not how/when does the modified version of outputs.json get written back to somewhere outside the file space specific to the instance of the docker container that the researcher is interacting with??

@jim-smith /data was mounted as read-only, which prevented writes. I have changed that to r/w. However, the ./outputs volume in the docker-compose.yml is already read-write and bind-mounted to the host, so any approved output zips generated by the "Approve and Download" action get written directly to the ./outputs folder on the host in real time.

@jim-smith
Copy link
Copy Markdown
Collaborator

@JessUWE

  1. I had to overwrite the current sacro-viewer/outputs folder with the folder created by a different demo session as the one on GitHub is empty - hence the 'results/json' not found error I was seeing
  2. if you add a file, it gives you a drop don menu to choose file type - but quite a few of the options (e.g.'plot') lead to an 'invalid option' message - so maybe not show these until there is supporting code to handle them?
  3. when an output checker clicks on release and download, then inputs some message, they get the two buttons.
  • pressing the first one 'download approved outputs' I get this message:

Page not found (404)

Request Method: | POST -- | -- http://localhost:8000/review/current/approved-outputs/ sacro.views.approved_outputs

Using the URLconf defined in sacro.urls, Django tried these URL patterns, in this order:

  1. [name='role-selection']
  2. checker/ [name='checker']
  3. load/ [name='load']
  4. contents/ [name='contents']
  5. error/ [name='error']
  6. review/ [name='review-create']
  7. review/<str:pk>/ [name='review-detail']
  8. review/<str:pk>/approved-outputs/ [name='approved-outputs']

The current path, review/current/approved-outputs/, matched the last one.

You’re seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

@jim-smith
Copy link
Copy Markdown
Collaborator

@JessUWE happy to approve this if you will create a separate issue for the unsupported items in the drop-down menu for 'output type' in researcher mode

I wonder if we need to be more explicit (in developers.md and/or somewhere else) that the directory containing the main 'session' needs to be called outputs because it is hard mapped by the docker?

Comment thread DEVELOPERS.md
```

### Troubleshooting

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is where we say "not seeing the data/outpuyts you expect? - they need to be in directory called outputs' in the same folder that the docker image is created from

Copy link
Copy Markdown
Collaborator

@jim-smith jim-smith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to approve but where do we tell people the the session results have to be in a folder called outputs, and does it need ot be there when the docker is created? or can that mapping be done later at run-time?

ps: these re usability things not tech things.

@JessUWE
Copy link
Copy Markdown
Contributor Author

JessUWE commented Apr 14, 2026

@JessUWE happy to approve this if you will create a separate issue for the unsupported items in the drop-down menu for 'output type' in researcher mode

I wonder if we need to be more explicit (in developers.md and/or somewhere else) that the directory containing the main 'session' needs to be called outputs because it is hard mapped by the docker?

@jim-smith can please you clarify what you mean by unsupported? at the minute everything in the dropdown works, are you getting an error? if yes could you elaborate on what you are getting?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Containerize SACRO Viewer with Docker

2 participants