-
Notifications
You must be signed in to change notification settings - Fork 0
build: Container #7
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a07a92a
feat: add Dockerfiles and .dockerignore for frontend and backend cont…
ChristianBeilschmidt f6db1d0
feat: add proxy configuration and update API base URL in user service
ChristianBeilschmidt cad2559
feat: add Kubernetes manifests for container deployment
ChristianBeilschmidt ab3f830
feat: add container workflow for nightly builds and push to Quay
ChristianBeilschmidt 888ccd8
ci: add container builds job to CI workflow and update frontend Docke…
ChristianBeilschmidt 74f002c
docs: update comment in Dockerfile to clarify caching best practices
ChristianBeilschmidt 9676907
fix: specify full image path for Caddy and Postgres in Dockerfile and…
ChristianBeilschmidt 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
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,65 @@ | ||
| name: Create containers | ||
|
|
||
| on: | ||
| # run every night | ||
| schedule: | ||
| - cron: "0 22 * * *" | ||
|
|
||
| # schedule manually | ||
| workflow_dispatch: | ||
| inputs: | ||
| # On workflow dispatch, `branch` is selected by default | ||
| # You can access it in `github.ref_name` | ||
|
|
||
| tag_name: | ||
| description: "Tag name for the container" | ||
| required: true | ||
| default: "nightly" | ||
|
|
||
| container_repository_branch: | ||
| description: "Branch of the container repository" | ||
| required: true | ||
| default: "main" | ||
|
|
||
| jobs: | ||
| build-and-push-containers: | ||
| name: Build and push container images to Quay | ||
| if: github.event_name != 'schedule' || github.repository_owner == 'geo-engine' | ||
|
|
||
| runs-on: ubuntu-24.04 | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| TAG_NAME: nightly | ||
| BACKEND_CONTAINER_NAME: biois-backend | ||
| FRONTEND_CONTAINER_NAME: biois-frontend | ||
|
|
||
| steps: | ||
| - name: Modify TAG_NAME if on `tag_name` is set on `workflow_dispatch` | ||
| if: github.event.inputs.tag_name != '' | ||
| run: | | ||
| echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV | ||
|
|
||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Login to quay.io | ||
| run: podman login -u="geoengine+bot" -p="${{secrets.QUAY_IO_TOKEN}}" quay.io | ||
|
|
||
| - name: Build containers | ||
| run: | | ||
| just build-backend-container | ||
| just build-frontend-container | ||
|
|
||
| - name: Push image to quay.io | ||
| run: | | ||
| podman push ${{env.BACKEND_CONTAINER_NAME}}:${{env.TAG_NAME}} quay.io/geoengine/${{env.BACKEND_CONTAINER_NAME}}:${{env.TAG_NAME}} | ||
| podman push ${{env.FRONTEND_CONTAINER_NAME}}:${{env.TAG_NAME}} quay.io/geoengine/${{env.FRONTEND_CONTAINER_NAME}}:${{env.TAG_NAME}} | ||
|
|
||
| - name: Push nightly with date | ||
| if: env.TAG_NAME == 'nightly' | ||
| run: | | ||
| podman push ${{env.BACKEND_CONTAINER_NAME}}:${{env.TAG_NAME}} quay.io/geoengine/${{env.BACKEND_CONTAINER_NAME}}:${{env.TAG_NAME}}-$(date +'%Y-%m-%d') | ||
| podman push ${{env.FRONTEND_CONTAINER_NAME}}:${{env.TAG_NAME}} quay.io/geoengine/${{env.FRONTEND_CONTAINER_NAME}}:${{env.TAG_NAME}}-$(date +'%Y-%m-%d') |
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
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,11 @@ | ||
| target | ||
| .git | ||
| .gitignore | ||
| node_modules | ||
| dist | ||
| *.log | ||
| *.env | ||
| /.venv | ||
| # Keep Cargo.lock in context for reproducible builds | ||
| # Cargo.lock | ||
| **/target |
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,40 @@ | ||
| # Backend multi-stage build: | ||
| # 1. build with Rust | ||
| # 2. copy release binary into distroless final image | ||
|
|
||
| FROM quay.io/geoengine/devcontainer:latest AS builder | ||
|
|
||
| WORKDIR /usr/src/biois | ||
|
|
||
| # Cache dependencies: copy manifest first | ||
| COPY \ | ||
| Cargo.toml \ | ||
| Cargo.lock \ | ||
| rust-toolchain.toml \ | ||
| ./ | ||
| # create dummy src to allow caching of cargo registry build step | ||
| # This is a best practice so that code changes don't invalidate the entire cargo build cache | ||
| RUN mkdir src && printf "fn main() { println!(\"cargo build cache\"); }\n" > src/main.rs | ||
| RUN cargo build --release | ||
| RUN rm -rf src | ||
|
|
||
| # Copy full source and build the release binary | ||
| COPY conf ./conf | ||
| COPY migrations ./migrations | ||
| COPY src ./src | ||
| COPY build.rs ./build.rs | ||
| RUN cargo build --release --bin biois | ||
|
|
||
| # Strip the binary to reduce size if possible | ||
| RUN strip target/release/biois || true | ||
|
|
||
| # Final image: distroless for minimal attack surface and size | ||
| FROM gcr.io/distroless/cc-debian13:nonroot | ||
|
|
||
| # Copy ca-certificates and the built binary | ||
| COPY --from=builder /usr/src/biois/target/release/biois /usr/local/bin/biois | ||
| COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
michaelmattig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| USER nonroot | ||
| EXPOSE 4040 | ||
| ENTRYPOINT ["/usr/local/bin/biois"] | ||
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,12 @@ | ||
| node_modules | ||
| dist | ||
| .git | ||
| .gitignore | ||
| npm-debug.log | ||
| yarn-error.log | ||
| .cache | ||
| /.idea | ||
| /.vscode | ||
| coverage | ||
| docs | ||
| *.local |
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,34 @@ | ||
| { | ||
| # Disable Caddy admin api | ||
| admin off | ||
| } | ||
|
|
||
| :80 | ||
|
|
||
| # Enable Compression | ||
| encode zstd gzip | ||
|
|
||
| # Proxy API requests to the backend | ||
| handle /api* { | ||
| uri strip_prefix /api | ||
|
|
||
| reverse_proxy biois-backend:4040 | ||
| } | ||
|
|
||
| # Match static assets | ||
| @static { | ||
| file | ||
| path *.js *.css *.png *.jpg *.jpeg *.gif *.svg *.ico *.woff *.woff2 | ||
| } | ||
|
|
||
| # Set Cache-Control to 1 day (86400 seconds) | ||
| header @static Cache-Control "public, max-age=86400" | ||
|
|
||
| # ALWAYS keep index.html fresh | ||
| header /index.html Cache-Control "no-cache, no-store, must-revalidate" | ||
|
|
||
| handle { | ||
| root * /usr/share/caddy | ||
| try_files {path} /index.html | ||
| file_server | ||
| } |
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 @@ | ||
| # Frontend multi-stage build: | ||
| # 1. build with devcontainer | ||
| # 2. serve static with Caddy | ||
|
|
||
| FROM quay.io/geoengine/devcontainer:latest AS builder | ||
|
|
||
| # 1.1 Install dependencies | ||
|
|
||
| WORKDIR /app/frontend | ||
| COPY frontend/package*.json ./ | ||
| RUN npm ci --silent | ||
|
|
||
| WORKDIR /app/api-client/typescript | ||
| COPY api-client/typescript . | ||
| RUN npm install --silent | ||
|
|
||
| # 1.2 Copy source and build | ||
| WORKDIR /app/frontend | ||
| COPY frontend/public ./public | ||
| COPY frontend/src ./src | ||
| COPY \ | ||
| frontend/_theme-colors.scss \ | ||
| frontend/angular.json \ | ||
| frontend/tsconfig*.json \ | ||
| ./ | ||
| RUN npm run build --silent | ||
|
|
||
| # 2. Final image: Caddy to serve static files and reverse-proxy API | ||
| FROM docker.io/caddy:2-alpine AS runner | ||
|
|
||
| # Copy built site into caddy's web root | ||
| COPY --from=builder /app/frontend/dist/BioIS/browser /usr/share/caddy | ||
|
|
||
| # Copy Caddyfile for SPA fallback and API proxy | ||
| COPY frontend/Caddyfile /etc/caddy/Caddyfile | ||
|
|
||
| EXPOSE 80 | ||
| CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"] |
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
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,9 @@ | ||
| { | ||
| "/api": { | ||
| "target": "http://localhost:4040", | ||
| "secure": false, | ||
| "changeOrigin": true, | ||
| "logLevel": "info", | ||
| "pathRewrite": { "^/api": "" } | ||
| } | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.