Skip to content

Minimize docker image for the web app.#321

Open
abecerra wants to merge 12 commits intomainfrom
docker-stage
Open

Minimize docker image for the web app.#321
abecerra wants to merge 12 commits intomainfrom
docker-stage

Conversation

@abecerra
Copy link
Copy Markdown
Contributor

@abecerra abecerra commented Apr 28, 2026

The idea: running the python-dev container for development and the python one for production

Running on https://bca-dev.hpc.crg.es/

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

This comment was marked as outdated.

@github-actions

This comment has been minimized.

@abecerra abecerra requested a review from nuno-agostinho April 28, 2026 09:54
Copy link
Copy Markdown
Member

@nuno-agostinho nuno-agostinho left a comment

Choose a reason for hiding this comment

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

Hi Andrés, thanks for the PR. The image is not being built in the GitHub Actions, do you know why?

Comment thread Dockerfile Outdated
Comment thread entrypoint.sh Outdated
Comment thread compose.prod.yml
@nuno-agostinho nuno-agostinho added the enhancement Improvements to existing features label Apr 28, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

Super-linter summary

Language Validation result
BASH_EXEC Pass ✅
CHECKOV Pass ✅
DOCKERFILE_HADOLINT Pass ✅
EDITORCONFIG Pass ✅
GITHUB_ACTIONS Pass ✅
GITHUB_ACTIONS_ZIZMOR Pass ✅
GITLEAKS Pass ✅
GIT_MERGE_CONFLICT_MARKERS Pass ✅
JSCPD Pass ✅
SHELL_SHFMT Pass ✅
SPELL_CODESPELL Pass ✅
YAML Pass ✅
YAML_PRETTIER Pass ✅

All files and directories linted successfully

For more information, see the GitHub Actions workflow run

Powered by Super-linter

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Super-linter summary

Language Validation result
BASH_EXEC Pass ✅
CHECKOV Pass ✅
DOCKERFILE_HADOLINT Pass ✅
EDITORCONFIG Pass ✅
GITHUB_ACTIONS Pass ✅
GITHUB_ACTIONS_ZIZMOR Pass ✅
GITLEAKS Pass ✅
GIT_MERGE_CONFLICT_MARKERS Pass ✅
JSCPD Pass ✅
SHELL_SHFMT Pass ✅
SPELL_CODESPELL Pass ✅
YAML Pass ✅
YAML_PRETTIER Pass ✅

All files and directories linted successfully

For more information, see the GitHub Actions workflow run

Powered by Super-linter

Comment thread Dockerfile
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you please cleanup this file for readability? For instance:

  • Use newlines to separate different concepts.
  • Each indentation should be of 4 spaces.
  • Consecutive spaces should be one space only.
  • Remove the first comment (# checkov:skip=CKV_DOCKER_3) that should no longer be needed (hopefully).

Comment thread Dockerfile Outdated
COPY . .
# Install frontend dependencies and prepare files
RUN mkdir -p static && chmod go+rx static && bun install && bun run build
CMD ["python", "manage.py", "collectstatic", "--noinput"]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This command is never run, so the static folder won't be populated with the latest files for production use by Django. Also, the app should still be served at the end of staging.

Suggested change
CMD ["python", "manage.py", "collectstatic", "--noinput"]
RUN python manage.py collectstatic --noinput
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

That said, I don't think this approach will work. The static directory will be mounted and override anything built into the image. It makes more sense to move the bun and collecstatic commands to entrypoint.sh, as before. This also avoids bloating the image with the big dataset/species static assets.

We should test this thoroughly before trying in production.

Comment thread Dockerfile Outdated
CMD curl -f http://localhost:8000/health/ || exit 1

EXPOSE 8000
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This command should only be used in staging. Since this image is specific for production, the last command should use gunicorn:

Suggested change
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
CMD ["gunicorn", "config.wsgi", "--bind", "0.0.0.0:8000"]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Super-linter summary

Language Validation result
BASH_EXEC Pass ✅
CHECKOV Pass ✅
DOCKERFILE_HADOLINT Pass ✅
EDITORCONFIG Pass ✅
GITHUB_ACTIONS Pass ✅
GITHUB_ACTIONS_ZIZMOR Pass ✅
GITLEAKS Pass ✅
GIT_MERGE_CONFLICT_MARKERS Pass ✅
JSCPD Pass ✅
SHELL_SHFMT Pass ✅
SPELL_CODESPELL Pass ✅
YAML Pass ✅
YAML_PRETTIER Pass ✅

All files and directories linted successfully

For more information, see the GitHub Actions workflow run

Powered by Super-linter

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

Labels

enhancement Improvements to existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants