Skip to content

Add frontend build stage to Docker#198

Merged
gjcthinkst merged 1 commit intomasterfrom
build_frontend_dist
Jan 23, 2026
Merged

Add frontend build stage to Docker#198
gjcthinkst merged 1 commit intomasterfrom
build_frontend_dist

Conversation

@gjcthinkst
Copy link
Contributor

Proposed changes

Instead of building and committing the frontend dist to the repo, we can instead build the frontend dist as part of building the Docker image. We use a separate stage to ensure that the node tooling doesn't end up in the final image.

Types of changes

What types of changes does your code introduce to this repository?

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update

Checklist

  • Lint and unit tests pass locally with my changes (if applicable)
  • I have run pre-commit (pre-commit in the repo)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Linked to the relevant github issue or github discussion

Testing

Built the Docker image locally specifying the GITHUB_SHA build arg. Ran the frontend Python service in the container, loaded the frontend in a browser and did spot checks to see that the frontend was correctly built and working as expected. Also checked that the same GITHUB_SHA was shown at the bottom of the page as the build ID.

$ docker build --build-arg GITHUB_SHA=masterabc -t canarytokens-docker-test:latest ./canarytokens
$ docker run -it --network=tokenstest -p 8082:8082 -v "$(pwd)/frontend.env.dist:/srv/frontend/frontend.env" -v "$(pwd)/switchboard.env.dist:/srv/switchboard/switchboard.env" canarytokens-docker-test /bin/bash
$ poetry run python -m uvicorn app:app --host 0.0.0.0 --port 8082


# copy the built frontend assets
RUN rm -rf /srv/dist
COPY --from=frontend-builder /build/dist /srv/dist

Choose a reason for hiding this comment

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

Just a quick doublecheck that this shouldn't perhaps be /build/frontend/dist ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The dist is indeed built in the parent directory of the frontend source (I'm not sure why)

@thinkst-louis thinkst-louis self-requested a review January 23, 2026 07:37
Copy link

@thinkst-louis thinkst-louis left a comment

Choose a reason for hiding this comment

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

LGTM

@gjcthinkst gjcthinkst merged commit 5eca4ba into master Jan 23, 2026
1 check passed
@gjcthinkst gjcthinkst deleted the build_frontend_dist branch January 23, 2026 08:13
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.

2 participants