Skip to content

Commit

Permalink
✨ Initial JupyterLab image (#3)
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Woffenden <jacob.woffenden@digital.justice.gov.uk>
  • Loading branch information
Jacob Woffenden authored Aug 15, 2024
1 parent a81de31 commit 65d400f
Show file tree
Hide file tree
Showing 19 changed files with 412 additions and 73 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.11.0",
"resolved": "ghcr.io/devcontainers/features/docker-in-docker@sha256:503f23cd692325b3cbb8c20a0ecfabb3444b0c786b363e0c82572bd7d71dc099",
"integrity": "sha256:503f23cd692325b3cbb8c20a0ecfabb3444b0c786b363e0c82572bd7d71dc099"
},
"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"
}
}
}
18 changes: 18 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "analytical-platform-jupyterlab",
"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"
]
}
}
}
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
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
35 changes: 15 additions & 20 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
---
# 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"
commit-message:
prefix: ":dependabot: github-actions"
include: "scope"
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "gomod"
commit-message:
prefix: ":dependabot: devcontainers"
include: "scope"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "docker"
commit-message:
prefix: ":dependabot: docker"
include: "scope"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: ":dependabot: pip"
include: "scope"
5 changes: 4 additions & 1 deletion .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 @@ -23,6 +25,7 @@ jobs:
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Dependency Review
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Install cosign
id: install_cosign
uses: sigstore/cosign-installer@4959ce089c160fddf62f7b42464195ba1a56d382 # v3.6.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@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.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@ab9d16d4b419c9d1a02df5213fa0ebe965ca5a57 # v0.17.1
with:
image: ghcr.io/${{ github.repository }}:${{ github.ref_name }}
format: cyclonedx-json
output-file: 'sbom.cyclonedx.json'

- name: Attest
uses: actions/attest-build-provenance@310b0a4a3b0b78ef57ecda988ee04b132db73ef8 # v1.4.1
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@f19ab44411e02574a74181cec8eb584319d0f779 # v1.4.0
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 }}
37 changes: 37 additions & 0 deletions .github/workflows/scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- 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@6e7b7d1fd3e4fef0c5fa8cce1229c54b2c9bd0d8 # v0.24.0
with:
image-ref: ghcr.io/${{ github.repository }}:${{ github.sha }}
severity: HIGH,CRITICAL
exit-code: 1
34 changes: 34 additions & 0 deletions .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0

- name: Super-Linter
id: super_linter
uses: super-linter/super-linter/slim@b4515bd4ad9d0aa4681960e053916ab991bdbe96 # v6.8.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

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

- name: Test
id: test
shell: bash
env:
IMAGE_TAG: ${{ github.sha }}
run: |
make test
16 changes: 16 additions & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Python
## setuptools
CVE-2024-6345 # TODO: @jacobwoffenden - Figure out where this comes from and patch it

# .NET
## We are running the latest dotnet-sdk from Ubuntu
CVE-2024-0057
CVE-2024-38095
CVE-2024-0057
CVE-2024-0057
CVE-2024-38095
CVE-2024-0057

# Go
## aws-sso
CVE-2024-41110 # Vulnerability in github.com/docker/docker, but we don't run Docker on CDE
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ghcr.io/ministryofjustice/analytical-platform-cloud-development-environment-base@sha256:c5b1ca761b4a9db72506ed23831c525df52e5398177c041638d8f0b80c47356e

LABEL org.opencontainers.image.vendor="Ministry of Justice" \
org.opencontainers.image.authors="Analytical Platform (analytical-platform@digital.justice.gov.uk)" \
org.opencontainers.image.title="JupyterLab" \
org.opencontainers.image.description="JupyterLab image for Analytical Platform" \
org.opencontainers.image.url="https://github.com/ministryofjustice/analytical-platform-jupyterlab"

ENV JUPYTERLAB_VERSION="4.2.4" \
JUPYTERLAB_GIT_VERSION="0.50.1"

SHELL ["/bin/bash", "-e", "-u", "-o", "pipefail", "-c"]

# First Run Notice
COPY --chown="${CONTAINER_USER}:${CONTAINER_GROUP}" --chmod=0644 src${ANALYTICAL_PLATFORM_DIRECTORY}/first-run-notice.txt ${ANALYTICAL_PLATFORM_DIRECTORY}/first-run-notice.txt

# JupyterLab
COPY --chown="${CONTAINER_USER}:${CONTAINER_GROUP}" --chmod=0644 src${ANALYTICAL_PLATFORM_DIRECTORY}/requirements.txt ${ANALYTICAL_PLATFORM_DIRECTORY}/requirements.txt
RUN <<EOF
pip install --no-cache-dir --requirement ${ANALYTICAL_PLATFORM_DIRECTORY}/requirements.txt
EOF

USER ${CONTAINER_USER}
WORKDIR /home/${CONTAINER_USER}
EXPOSE 8080
COPY --chown=nobody:nobody --chmod=0755 src/usr/local/bin/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY --chown=nobody:nobody --chmod=0755 src/usr/local/bin/healthcheck.sh /usr/local/bin/healthcheck.sh
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 65d400f

Please sign in to comment.