-
Notifications
You must be signed in to change notification settings - Fork 1
[GPCAPIM-289] - Add dependacies to dev container image #117
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
Changes from all commits
b066ec2
05bebcb
214ace4
0abf492
21c9b90
ec9779d
4e54208
5fdef33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -436,24 +436,25 @@ jobs: | |
| body: lines.join('\n'), | ||
| }); | ||
|
|
||
| # ---------- Security scanning ---------- | ||
| - name: Trivy IaC scan | ||
| if: github.event.action != 'closed' | ||
| uses: nhs-england-tools/trivy-action/iac-scan@289984b2f03034233a347d6dbadecd5ca9ea9634 | ||
| with: | ||
| scan-ref: infrastructure/environments/preview | ||
| artifact-name: trivy-iac-scan-${{ steps.meta.outputs.branch_name }} | ||
|
|
||
| - name: Trivy image scan | ||
| if: github.event.action != 'closed' | ||
| uses: nhs-england-tools/trivy-action/image-scan@289984b2f03034233a347d6dbadecd5ca9ea9634 | ||
| with: | ||
| image-ref: ${{steps.meta.outputs.ecr_url}}:${{steps.meta.outputs.branch_name}} | ||
| artifact-name: trivy-image-scan-${{ steps.meta.outputs.branch_name }} | ||
|
|
||
| - name: Generate SBOM | ||
| if: github.event.action != 'closed' | ||
| uses: nhs-england-tools/trivy-action/image-scan@289984b2f03034233a347d6dbadecd5ca9ea9634 | ||
| with: | ||
| image-ref: ${{steps.meta.outputs.ecr_url}}:${{steps.meta.outputs.branch_name}} | ||
| artifact-name: trivy-sbom-${{ steps.meta.outputs.branch_name }} | ||
| # desable trivy in light of attack https://socket.dev/blog/trivy-under-attack-again-github-actions-compromise | ||
| # # ---------- Security scanning ---------- | ||
| # - name: Trivy IaC scan | ||
| # if: github.event.action != 'closed' | ||
| # uses: nhs-england-tools/trivy-action/iac-scan@289984b2f03034233a347d6dbadecd5ca9ea9634 | ||
| # with: | ||
| # scan-ref: infrastructure/environments/preview | ||
| # artifact-name: trivy-iac-scan-${{ steps.meta.outputs.branch_name }} | ||
|
|
||
| # - name: Trivy image scan | ||
| # if: github.event.action != 'closed' | ||
| # uses: nhs-england-tools/trivy-action/image-scan@289984b2f03034233a347d6dbadecd5ca9ea9634 | ||
| # with: | ||
| # image-ref: ${{steps.meta.outputs.ecr_url}}:${{steps.meta.outputs.branch_name}} | ||
| # artifact-name: trivy-image-scan-${{ steps.meta.outputs.branch_name }} | ||
|
|
||
| # - name: Generate SBOM | ||
| # if: github.event.action != 'closed' | ||
| # uses: nhs-england-tools/trivy-action/image-scan@289984b2f03034233a347d6dbadecd5ca9ea9634 | ||
| # with: | ||
| # image-ref: ${{steps.meta.outputs.ecr_url}}:${{steps.meta.outputs.branch_name}} | ||
| # artifact-name: trivy-sbom-${{ steps.meta.outputs.branch_name }} | ||
|
Comment on lines
+439
to
+460
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ endif | |
| IMAGE_NAME := ${IMAGE_REPOSITORY}:${IMAGE_TAG} | ||
| COMMIT_VERSION := $(shell git rev-parse --short HEAD) | ||
| BUILD_DATE := $(shell date -u +"%Y%m%d") | ||
| INCLUDE_DEV_CERTS ?= ${DEV_CERTS_INCLUDED} | ||
| # ============================================================================== | ||
|
|
||
| # Example CI/CD targets are: dependencies, build, publish, deploy, clean, etc. | ||
|
|
@@ -41,13 +42,25 @@ build-gateway-api: dependencies | |
| @rm -rf ../infrastructure/images/gateway-api/resources/build/ | ||
| @mkdir ../infrastructure/images/gateway-api/resources/build/ | ||
| @cp -r ./target/gateway-api ../infrastructure/images/gateway-api/resources/build/ | ||
| # If dev certificates are present inside the dev container, copy them into | ||
| # the gateway-api image build context so they can be installed there too. | ||
| @if [ -d "/resources/dev-certificates" ]; then \ | ||
| rm -rf ../infrastructure/images/gateway-api/resources/dev-certificates; \ | ||
DWolfsNHS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| mkdir -p ../infrastructure/images/gateway-api/resources/dev-certificates; \ | ||
| cp -r /resources/dev-certificates/* ../infrastructure/images/gateway-api/resources/dev-certificates/; \ | ||
DWolfsNHS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fi | ||
| # Remove temporary build artefacts once build has completed | ||
| @rm -rf target && rm -rf dist | ||
|
|
||
| .PHONY: build | ||
| build: build-gateway-api # Build the project artefact @Pipeline | ||
| @echo "Building Docker x86 image using Docker. Utilising python version: ${PYTHON_VERSION} ..." | ||
| @$(docker) buildx build --platform linux/amd64 --load --provenance=false --build-arg PYTHON_VERSION=${PYTHON_VERSION} --build-arg COMMIT_VERSION=${COMMIT_VERSION} --build-arg BUILD_DATE=${BUILD_DATE} -t ${IMAGE_NAME} infrastructure/images/gateway-api | ||
| @if [[ -n "$${IN_BUILD_CONTAINER}" ]]; then \ | ||
| echo "building with dev certs ..." ; \ | ||
| $(docker) buildx build --platform linux/amd64 --load --provenance=false --build-arg PYTHON_VERSION=${PYTHON_VERSION} --build-arg COMMIT_VERSION=${COMMIT_VERSION} --build-arg BUILD_DATE=${BUILD_DATE} --build-arg INCLUDE_DEV_CERTS=${INCLUDE_DEV_CERTS} -t ${IMAGE_NAME} infrastructure/images/gateway-api | ||
| else \ | ||
| $(docker) buildx build --platform linux/amd64 --load --provenance=false --build-arg PYTHON_VERSION=${PYTHON_VERSION} --build-arg COMMIT_VERSION=${COMMIT_VERSION} --build-arg BUILD_DATE=${BUILD_DATE} -t ${IMAGE_NAME} infrastructure/images/gateway-api | ||
| fi | ||
|
Comment on lines
+58
to
+63
|
||
| @echo "Docker image '${IMAGE_NAME}' built successfully!" | ||
|
|
||
| publish: # Publish the project artefact @Pipeline | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,13 +2,25 @@ | |
| ARG PYTHON_VERSION=invalid | ||
| FROM python:${PYTHON_VERSION}-alpine3.23 AS gateway-api | ||
|
|
||
| # Controls whether dev certificates (if present) are installed into this image. | ||
| ARG INCLUDE_DEV_CERTS=false | ||
|
|
||
| COPY resources/ /resources | ||
|
|
||
| # Install required certificates for dev machines. | ||
| RUN if [ "$INCLUDE_DEV_CERTS" = "true" ] && [ -d /resources/dev-certificates ]; then \ | ||
|
Check warning on line 11 in infrastructure/images/gateway-api/Dockerfile
|
||
| cp -r /resources/dev-certificates/* /usr/local/share/ca-certificates/; \ | ||
| update-ca-certificates; \ | ||
| cp -r /resources/dev-certificates/* /etc/ssl/certs/; \ | ||
| else \ | ||
| rm -rf /resources/dev-certificates || true; \ | ||
| fi | ||
|
|
||
| RUN apk upgrade --no-cache && \ | ||
| pip install --no-cache-dir --upgrade pip && \ | ||
| addgroup -S nonroot && \ | ||
| adduser -S gateway_api_user -G nonroot | ||
|
Comment on lines
+8
to
22
|
||
|
|
||
| COPY resources/ /resources | ||
|
|
||
| WORKDIR /resources/build/gateway-api | ||
|
|
||
| ENV PYTHONPATH=/resources/build/gateway-api | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| /build | ||
| /dev-certificates |
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.
Spelling: "desable" should be "disable" in this workflow comment to keep the rationale clear/searchable (especially since this is documenting a security-related change).