Skip to content

Commit

Permalink
✨ Initial image (#3)
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Woffenden <[email protected]>
  • Loading branch information
Jacob Woffenden authored Oct 15, 2024
1 parent a6ce141 commit b2c0dfc
Show file tree
Hide file tree
Showing 24 changed files with 786 additions and 77 deletions.
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "2.12.0",
"resolved": "ghcr.io/devcontainers/features/docker-in-docker@sha256:5f3e2005aad161ce3ff7700b2603f11935348c039f9166960efd050d69cd3014",
"integrity": "sha256:5f3e2005aad161ce3ff7700b2603f11935348c039f9166960efd050d69cd3014"
},
"ghcr.io/ministryofjustice/devcontainer-feature/container-structure-test:1": {
"version": "1.0.0",
"resolved": "ghcr.io/ministryofjustice/devcontainer-feature/container-structure-test@sha256:19eb30f9eb327b667be2002757d55381de87cdb5a79a6e37d293369fe8ad01ad",
"integrity": "sha256:19eb30f9eb327b667be2002757d55381de87cdb5a79a6e37d293369fe8ad01ad",
"dependsOn": [
"ghcr.io/devcontainers/features/docker-in-docker:2"
]
},
"ghcr.io/ministryofjustice/devcontainer-feature/static-analysis:1": {
"version": "1.0.0",
"resolved": "ghcr.io/ministryofjustice/devcontainer-feature/static-analysis@sha256:e81d52725655c8ffb861605feac7ad155b447d51af65f6c3a03cab32d59f1e16",
"integrity": "sha256:e81d52725655c8ffb861605feac7ad155b447d51af65f6c3a03cab32d59f1e16"
}
}
}
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "analytical-platform-cloud-development-environment-nginx-proxy",
"image": "ghcr.io/ministryofjustice/devcontainer-base:latest",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/ministryofjustice/devcontainer-feature/container-structure-test:1": {},
"ghcr.io/ministryofjustice/devcontainer-feature/static-analysis:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"EditorConfig.EditorConfig",
"GitHub.vscode-github-actions",
"GitHub.vscode-pull-request-github",
"sumneko.lua"
],
"settings": {
"files.associations": {
"src/etc/nginx/nginx.conf.template": "properties"
}
}
}
}
}
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.json]
indent_style = space
indent_size = 2

[*.sh]
indent_style = space
indent_size = 2

[{*.yml,*.yaml}]
indent_style = space
indent_size = 2

# This file is autogenerated
[.devcontainer/devcontainer-lock.json]
end_of_line = unset
insert_final_newline = unset
4 changes: 1 addition & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# Add a team or username to this file
# Example:
# * @ministryofjustice/operations-engineering
* @ministryofjustice/analytical-platform
32 changes: 10 additions & 22 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,25 @@
---
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2

updates:
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "terraform"
directory: "/terraform"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "gomod"
commit-message:
prefix: ":dependabot: github-actions"
include: "scope"
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: ":dependabot: devcontainers"
include: "scope"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: ":dependabot: docker"
include: "scope"
9 changes: 6 additions & 3 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
name: Dependency Review
name: 🔍 Dependency Review

on:
pull_request:
branches:
- main
types:
- edited
- opened
Expand All @@ -20,9 +22,10 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1

- name: Dependency Review
uses: actions/dependency-review-action@9129d7d40b8c12c1ed0f60400d00c92d437adcce # v4.1.3
id: dependency_review
uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4
with:
fail-on-severity: critical
91 changes: 91 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
name: 🔖 Release

on:
push:
tags:
- "*"

permissions: {}

jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
actions: read
attestations: write
contents: write
id-token: write
packages: write
steps:
- name: Checkout
id: checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1

- name: Install cosign
id: install_cosign
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0

- name: Log in to GitHub Container Registry
id: ghcr_login
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push
id: build_and_push
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
with:
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.ref_name }}

- name: Sign
id: sign
shell: bash
run: |
cosign sign --yes ghcr.io/${{ github.repository }}@${{ steps.build_and_push.outputs.digest }}
- name: Generate SBOM
id: generate_sbom
uses: anchore/sbom-action@f5e124a5e5e1d497a692818ae907d3c45829d033 # v0.17.3
with:
image: ghcr.io/${{ github.repository }}:${{ github.ref_name }}
format: cyclonedx-json
output-file: "sbom.cyclonedx.json"

- name: Attest
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
id: attest
with:
subject-name: ghcr.io/${{ github.repository }}
subject-digest: ${{ steps.build_and_push.outputs.digest }}
push-to-registry: true

- name: Attest SBOM
uses: actions/attest-sbom@5026d3663739160db546203eeaffa6aa1c51a4d6 # v1.4.1
id: attest_sbom
with:
subject-name: ghcr.io/${{ github.repository }}
subject-digest: ${{ steps.build_and_push.outputs.digest }}
sbom-path: sbom.cyclonedx.json
push-to-registry: true

- name: cosign Verify
id: cosign_verify
shell: bash
run: |
cosign verify \
--certificate-oidc-issuer=https://token.actions.githubusercontent.com \
--certificate-identity=https://github.com/${{ github.workflow_ref }} \
ghcr.io/${{ github.repository }}@${{ steps.build_and_push.outputs.digest }}
- name: GitHub Attestation Verify
id: gh_attestation_verify
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh attestation verify oci://ghcr.io/${{ github.repository }}:${{ github.ref_name }} --repo ${{ github.repository }}
40 changes: 40 additions & 0 deletions .github/workflows/scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: 🩻 Scan

on:
pull_request:
branches:
- main

permissions: {}

jobs:
scan:
name: Scan
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
id: checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1

- name: Build
id: build
shell: bash
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
IMAGE_TAG: ${{ github.sha }}
run: |
make build
- name: Scan
id: scan
uses: aquasecurity/trivy-action@5681af892cd0f4997658e2bacc62bd0a894cf564 # v0.27.0
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db:1
with:
image-ref: ghcr.io/${{ github.repository }}:${{ github.sha }}
severity: HIGH,CRITICAL
exit-code: 1
35 changes: 35 additions & 0 deletions .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: 🦝 Super-Linter

on:
pull_request:
branches:
- main
types:
- edited
- opened
- reopened
- synchronize

permissions: {}

jobs:
super-linter:
name: Super-Linter
runs-on: ubuntu-latest
permissions:
contents: read
statuses: write
steps:
- name: Checkout
id: checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
fetch-depth: 0

- name: Super-Linter
id: super_linter
uses: super-linter/super-linter/slim@b92721f792f381cedc002ecdbb9847a15ece5bb8 # v7.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_LUA: false
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: 🧪 Test

on:
pull_request:
branches:
- main

permissions: {}

jobs:
test:
name: Test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
id: checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1

- name: Set Up Container Structure Test
id: setup_container_structure_test
uses: ministryofjustice/github-actions/setup-container-structure-test@e08cbcac12ec9c09d867ab2b803d4ea1a87300ad # v18.2.4

- name: Test
id: test
shell: bash
env:
IMAGE_TAG: ${{ github.sha }}
run: |
make test
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file is generated automatically
.devcontainer/devcontainer-lock.json

# This file is out of scope right now
src/srv/www/404.html
9 changes: 9 additions & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# I am skipping these CVEs because while they are fixed in APK, I do not want to run `apk update && apk upgrade` as the image won't be reproducible
# We currently consume docker.io/openresty/openresty:1.25.3.2-alpine-fat but intend to refactor and switch to Ubuntu LTS for two reasons
# 1. We can fully control the base image, so nonroot and package version
# 2. OpenResty publish an APT distrobution we can use
CVE-2024-5171
CVE-2024-6197
CVE-2024-45490
CVE-2024-45491
CVE-2024-45492
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#checkov:skip=CKV_DOCKER_3: Current implementation uses off-the-shelf image from OpenResty which doesn't offer a nonroot variant

# docker.io/openresty/openresty:1.25.3.2-alpine-fat
FROM docker.io/openresty/openresty@sha256:aa8ea52fa35a296558aed8b392fb39d575e39dd4a7717fa44f1fd6fc09c1185d

LABEL org.opencontainers.image.vendor="Ministry of Justice" \
org.opencontainers.image.authors="Analytical Platform ([email protected])" \
org.opencontainers.image.title="Cloud Development Environment NGINX Proxy" \
org.opencontainers.image.description="Cloud Development Environment NGINX proxy image for Analytical Platform" \
org.opencontainers.image.url="https://github.com/ministryofjustice/analytical-platform-cloud-development-environment-nginx-proxy"

RUN <<EOF
luarocks install lua-resty-openidc 1.8.0
EOF

COPY src/etc/nginx /etc/nginx
COPY src/opt/lua-scripts /opt/lua-scripts
COPY src/srv/www /srv/www
COPY --chown=nobody:nobody --chmod=0755 src/usr/local/bin /usr/local/bin

EXPOSE 3000
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD ["/usr/local/bin/healthcheck.sh"]
Loading

0 comments on commit b2c0dfc

Please sign in to comment.