-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add container #2
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
Open
baylisscg
wants to merge
6
commits into
dptools:prescient
Choose a base branch
from
unimelb-eresearch-group:feat/add-container
base: prescient
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
98b199f
adds Mise-en-plase config files to `.gitignore`
baylisscg f801b83
adds container build files
baylisscg 77337e3
changes next.js' output mode to `standalone` to make container work. …
baylisscg 4981b80
adds `npm run build:container` and sets the default image name to ghc…
baylisscg c4bbe8a
adds Actions workflow and integrates with Bake file
baylisscg cf277eb
fix: fold in upstream workflow fixes
baylisscg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| .jj | ||
| .git | ||
| node_modules/ | ||
| container | ||
| .idea | ||
| .next |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: container-build.yaml | ||
| on: | ||
| push: | ||
| branches: | ||
| - prescient | ||
| pull_request: | ||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: ${{ github.repository }} | ||
| jobs: | ||
| bake: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| attestations: write | ||
| id-token: write | ||
| steps: | ||
| - name: Log in to the Container registry | ||
| uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| - name: Extract metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
| - name: Validate build configuration | ||
| uses: docker/bake-action@v6 | ||
| with: | ||
| files: | | ||
| ./container/docker-bake.hcl | ||
| targets: validate-build | ||
| - name: Build and push | ||
| id: push | ||
| uses: docker/bake-action@v6 | ||
| env: | ||
| SOURCE_DATE_EPOCH: 0 | ||
| with: | ||
| targets: dashboard | ||
| push: ${{ github.event_name != 'pull_request' }} # Push if not a pull request | ||
| pull: true | ||
| provenance: mode=min | ||
| sbom: true | ||
| files: | | ||
| ./container/docker-bake.hcl | ||
| cwd://${{ steps.meta.outputs.bake-file }} | ||
| set: | | ||
| *.cache-from=type=gha | ||
| *.cache-to=type=gha,mode=max |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,3 +39,7 @@ yarn-error.log* | |
| # typescript | ||
| *.tsbuildinfo | ||
| next-env.d.ts | ||
|
|
||
| # Ignore mise-en-plase config | ||
| mise.* | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # see docker-bake.hcl for definition of nodejs_lts context | ||
|
|
||
| # Install npm dependencies | ||
| FROM nodejs_lts AS deps | ||
| WORKDIR /app | ||
| COPY package.json package-lock.json* ./ | ||
| RUN npm ci | ||
|
|
||
| # Build nextjs app using dependencies above | ||
| FROM nodejs_lts AS builder | ||
| WORKDIR /app | ||
| COPY --from=deps /app/node_modules ./node_modules | ||
| COPY . . | ||
| RUN npm run build | ||
|
|
||
| # Build the actual container | ||
| FROM nodejs_lts AS runner | ||
|
|
||
| # Create a non-root user to own the process | ||
| RUN addgroup -g 1001 -S nodejs | ||
| RUN adduser -S nextjs -u 1001 | ||
|
|
||
| # Copy files from builders | ||
| COPY --from=builder /app/public ./public | ||
|
|
||
| # Automatically leverage output traces to reduce image size | ||
| # https://nextjs.org/docs/advanced-features/output-file-tracing | ||
| COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
| COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
|
|
||
| USER nextjs | ||
|
|
||
| EXPOSE 3000 | ||
|
|
||
| ENV PORT=3000 | ||
| ENV HOSTNAME="0.0.0.0" | ||
| CMD ["node","server.js"] | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // docker-bake.hcl | ||
| target "docker-metadata-action" {} | ||
|
|
||
| target "dashboard" { | ||
| inherits = ["docker-metadata-action"] | ||
| context = "." | ||
| description = "Builds a containerised version of the dashboard" | ||
| contexts = { | ||
| nodejs_lts = "docker-image://node:24-alpine" | ||
| } | ||
| dockerfile = "container/Dockerfile" | ||
| tags = [ | ||
| "ghcr.io/dptools/dashboard:latest", // pseudo container name | ||
| ] | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import type { NextConfig } from "next"; | ||
|
|
||
| const nextConfig: NextConfig = { | ||
| /* config options here */ | ||
| output: "standalone", | ||
| }; | ||
|
|
||
| export default nextConfig; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this require adding / configiring variables for this worflow environment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. They're all either defined in the Actions context or specified in the top level
envblock.