Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Multi-stage Docker build for app image #2392

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

thekaveman
Copy link
Member

@thekaveman thekaveman commented Sep 20, 2024

Closes #2389.

Fixes the issue with the dynamic version calculation being incorrect, because of a dirty git index during Docker build time / pip install time.

There's no reason to have the .git directory in the app image, same with all the extra files, tests, .devcontainer, etc.

Uses the approach from eligibility-server: https://github.com/cal-itp/eligibility-server/blob/main/Dockerfile

How to test

  1. Check out this branch locally
  2. Apply an annotated tag e.g. git tag -a 2024.09.99
  3. docker compose build --no-cache client to rebuild the app image
  4. docker compose up -d client to start a new app container
  5. docker compose exec -ti client /bin/bash to connect to running container
  6. python manage.py shell to enter a Django shell with settings loaded
  7. import benefits; print(benefits.VERSION)
  8. bin/rebuild.sh to rebuild the devcontainer
  9. Confirm you can launch the devcontainer ✅

image

@thekaveman thekaveman self-assigned this Sep 20, 2024
@github-actions github-actions bot added deployment-dev [auto] Changes that will trigger a deploy if merged to dev docker Application container, devcontainer, Compose, etc. labels Sep 20, 2024
Copy link

Coverage report

This PR does not seem to contain any modification to coverable code.

@thekaveman thekaveman marked this pull request as ready for review September 21, 2024 00:06
@thekaveman thekaveman requested a review from a team as a code owner September 21, 2024 00:06
fixes issue with version calculation from a dirty git index during
Docker build time / pip install time

there's no reason to have the .git directory in the app image, same with
all the extra files, tests, .devcontainer, etc.

same approach as eligibility-server's Dockerfile
since it is no longer available in the base app image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployment-dev [auto] Changes that will trigger a deploy if merged to dev docker Application container, devcontainer, Compose, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

App container is calculating an incorrect version number from tag
1 participant