From f3916785f0654671e0cf5a4feb215d1610690a68 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Wed, 20 Mar 2024 17:09:29 +0100 Subject: [PATCH 01/31] Update --- .github/workflows/cla.yaml | 18 +++ .github/workflows/deploy.yaml | 265 ++++++++++++++++++++++++++++++++++ Dockerfile | 37 +++++ init | 14 ++ scripts/install_sysdeps.sh | 23 +++ 5 files changed, 357 insertions(+) create mode 100644 .github/workflows/cla.yaml create mode 100644 .github/workflows/deploy.yaml create mode 100644 Dockerfile create mode 100644 init create mode 100644 scripts/install_sysdeps.sh diff --git a/.github/workflows/cla.yaml b/.github/workflows/cla.yaml new file mode 100644 index 0000000..b674b0b --- /dev/null +++ b/.github/workflows/cla.yaml @@ -0,0 +1,18 @@ +name: CLA ๐Ÿ” + +on: + issue_comment: + types: + - created + # For PRs that originate from forks + pull_request_target: + types: + - opened + - closed + - synchronize + +jobs: + CLA: + name: CLA ๐Ÿ“ + uses: insightsengineering/.github/.github/workflows/cla.yaml@main + secrets: inherit diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..7b43160 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,265 @@ +name: Deploy image to GHCR ๐Ÿช‚ + +env: + REGISTRY: ghcr.io + # PLATFORMs is a comma-separted list of architectures to build for. + # We disable linux/arm64 due to runner mem saturation. + PLATFORMS: linux/amd64 + +on: + # repository_dispatch: + # types: + # - scheduled + workflow_dispatch: + inputs: + origin: + description: DockerHub org or username where the base image is located + required: true + type: choice + default: "julia" + options: + - "julia" + + source_image_tag: + description: Source image tag + required: true + type: choice + default: "1.10-bookworm" + options: + - "1.10-bookworm" + + destination_image_name: + description: Destination image name + required: true + type: choice + default: "julia-vscode" + options: + - "julia-vscode" + + destination_image_tag: + description: Destination image tag + required: true + type: choice + default: "1.10-bookworm" + options: + - "1.10-bookworm" + + tag: + description: | + Custom Image Tag/Version. Defaults to current date in the `YYYY.MM.DD` + format if unspecified. + required: false + default: "" + + tag_latest: + description: Tag image as `latest` + default: false + type: boolean + + release_tag: + description: | + Release tag to which SBOM generated for image should be attached. + Release tags follow the `YYYY.MM.DD` format. + This must be specified if you want to upload artifacts to the release. + required: false + default: "" + +jobs: + normalize-inputs: + name: Normalize inputs ๐Ÿงน + runs-on: ubuntu-latest + steps: + - name: Normalize ๐Ÿงฝ + id: normalizer + run: | + function normalize() { + local var=$1 + if [ "$var" == "" ] + then { + var=$2 + } + fi + echo ${var} + } + ORIGIN=$(normalize ${{ github.event.inputs.origin }} ${{ github.event.client_payload.origin }}) + SOURCE_IMAGE_TAG=$(normalize ${{ github.event.inputs.source_image_tag }} ${{ github.event.client_payload.source_image_tag }}) + DESTINATION_IMAGE_NAME=$(normalize ${{ github.event.inputs.destination_image_name }} ${{ github.event.client_payload.destination_image_name }}) + DESTINATION_IMAGE_TAG=$(normalize ${{ github.event.inputs.destination_image_tag }} ${{ github.event.client_payload.destination_image_tag }}) + TAG=$(normalize ${{ github.event.inputs.tag }} ${{ github.event.client_payload.tag }}) + TAG_LATEST=$(normalize ${{ github.event.inputs.tag_latest }} ${{ github.event.client_payload.tag_latest }}) + RELEASE_TAG=$(normalize ${{ github.event.inputs.release_tag }} ${{ github.event.client_payload.release_tag }}) + echo "ORIGIN=$ORIGIN" >> $GITHUB_OUTPUT + echo "SOURCE_IMAGE_TAG=$SOURCE_IMAGE_TAG" >> $GITHUB_OUTPUT + echo "DESTINATION_IMAGE_NAME=$DESTINATION_IMAGE_NAME" >> $GITHUB_OUTPUT + echo "DESTINATION_IMAGE_TAG=$DESTINATION_IMAGE_TAG" >> $GITHUB_OUTPUT + echo "TAG=$TAG" >> $GITHUB_OUTPUT + echo "TAG_LATEST=$TAG_LATEST" >> $GITHUB_OUTPUT + echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_OUTPUT + shell: bash + outputs: + origin: ${{ steps.normalizer.outputs.ORIGIN }} + source_image_tag: ${{ steps.normalizer.outputs.SOURCE_IMAGE_TAG }} + destination_image_name: ${{ steps.normalizer.outputs.DESTINATION_IMAGE_NAME }} + destination_image_tag: ${{ steps.normalizer.outputs.DESTINATION_IMAGE_TAG }} + tag: ${{ steps.normalizer.outputs.TAG }} + tag_latest: ${{ steps.normalizer.outputs.TAG_LATEST }} + release_tag: ${{ steps.normalizer.outputs.RELEASE_TAG }} + + build: + runs-on: ubuntu-latest + needs: normalize-inputs + name: Build & Deploy ๐Ÿš€ ${{ needs.normalize-inputs.outputs.destination_image_name }}:${{ needs.normalize-inputs.outputs.destination_image_tag }} + + # Token permissions + permissions: + contents: read + packages: write + + # Build steps + steps: + - name: Reclaim Disk Space ๐Ÿšฎ + uses: insightsengineering/disk-space-reclaimer@v1 + with: + tools-cache: false + android: true + dotnet: true + haskell: true + large-packages: true + swap-storage: false + docker-images: true + + - name: Checkout repository ๐Ÿ’ณ + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + id: buildx + with: + install: true + + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v3 + with: + platforms: ${{ env.PLATFORMS }} + + - name: Cache Docker layers โ™ป๏ธ + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ needs.normalize-inputs.outputs.destination_image_name }}-${{ needs.normalize-inputs.outputs.destination_image_tag }} + restore-keys: | + ${{ runner.os }}-buildx-${{ needs.normalize-inputs.outputs.destination_image_name }}-${{ needs.normalize-inputs.outputs.destination_image_tag }} + ${{ runner.os }}-buildx-${{ needs.normalize-inputs.outputs.destination_image_name }} + ${{ runner.os }}-buildx- + + - name: Log in to the Container registry ๐Ÿ— + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set build variables ๐Ÿ“ + id: build_vars + run: | + # Set default tag as 'YYYY.MM.DD' date if it isn't set + tag="${{ needs.normalize-inputs.outputs.tag }}" + if [ "${tag}" == "" ] + then { + tag=$(date +%Y.%m.%d) + } + fi + + tag_latest="${{ needs.normalize-inputs.outputs.tag_latest }}" + image_name="${{ needs.normalize-inputs.outputs.destination_image_name }} + image_tag="${{ needs.normalize-inputs.outputs.destination_image_tag }} + + # Set full image name + full_names="${{ env.REGISTRY }}/${{ github.repository_owner }}/${image_name}:${tag}" + echo "OUTPUT_IMAGE_NAME=${full_names}" >> $GITHUB_OUTPUT + if [ "${tag_latest}" == "true" ] + then + full_names="$full_names,${{ env.REGISTRY }}/${{ github.repository_owner }}/${image_name}:latest" + fi + echo "FULL_NAMES=${full_names}" >> $GITHUB_OUTPUT + echo "FULL_NAMES=${full_names}" + + # Push the image if we're running for main + echo "github.ref = ${{ github.ref }}" + if [ "${{ github.ref }}" == 'refs/heads/main' ]; then + echo "DOCKER_PUSH=true" >> $GITHUB_OUTPUT + echo "DOCKER_PUSH = true" + else + echo "DOCKER_PUSH=false" >> $GITHUB_OUTPUT + echo "DOCKER_PUSH = false" + fi + + echo "SBOM_OUTPUT_FILENAME=$GITHUB_WORKSPACE/sbom.json" >> $GITHUB_OUTPUT + + - name: Build and push image ๐Ÿ— + uses: docker/build-push-action@v5 + with: + context: ./ + file: Dockerfile + push: ${{ steps.build_vars.outputs.DOCKER_PUSH }} + tags: ${{ steps.build_vars.outputs.FULL_NAMES }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + build-args: | + ORIGIN=${{ needs.normalize-inputs.outputs.origin }} + SOURCE_IMAGE_TAG=${{ needs.normalize-inputs.outputs.source_image_tag }} + DESTINATION_IMAGE_NAME=${{ needs.normalize-inputs.outputs.destination_image_name }} + DESTINATION_IMAGE_TAG=${{ needs.normalize-inputs.outputs.destination_image_tag }} + platforms: ${{ env.PLATFORMS }} + + - name: Generate image manifest ๐Ÿณ + run: | + docker manifest inspect ${{ steps.build_vars.outputs.OUTPUT_IMAGE_NAME }} > manifest.json + + # - name: Reclaim Disk Space for SBOM Generation ๐Ÿšฎ + # uses: insightsengineering/disk-space-reclaimer@v1 + # with: + # tools-cache: false + # android: true + # dotnet: true + # haskell: true + # large-packages: true + # swap-storage: false + # docker-images: true + + # - name: Generate SBOM ๐Ÿ“ƒ + # uses: anchore/sbom-action@v0 + # with: + # image: "${{ steps.build_vars.outputs.OUTPUT_IMAGE_NAME }}" + # output-file: "${{ steps.build_vars.outputs.SBOM_OUTPUT_FILENAME }}" + # artifact-name: "sbom.spdx" + + # - name: Upload image manifest to release ๐Ÿ”ผ + # uses: svenstaro/upload-release-action@v2 + # if: "${{ needs.normalize-inputs.outputs.release_tag }} != ''" + # with: + # repo_token: ${{ secrets.REPO_GITHUB_TOKEN }} + # file: "manifest.json" + # asset_name: "image.manifest.${{ steps.build_vars.outputs.OUTPUT_IMAGE_NAME }}.json" + # tag: "${{ needs.normalize-inputs.outputs.release_tag }}" + # overwrite: true + + # - name: Upload SBOM to release ๐Ÿ”ผ + # uses: svenstaro/upload-release-action@v2 + # if: "${{ needs.normalize-inputs.outputs.release_tag }} != ''" + # with: + # repo_token: ${{ secrets.REPO_GITHUB_TOKEN }} + # file: "${{ steps.build_vars.outputs.SBOM_OUTPUT_FILENAME }}" + # asset_name: "SBOM for ${{ steps.build_vars.outputs.OUTPUT_IMAGE_NAME }}.spdx.json" + # tag: "${{ needs.normalize-inputs.outputs.release_tag }}" + # overwrite: true + + # - name: Move cache โ™ป๏ธ + # run: | + # rm -rf /tmp/.buildx-cache + # if [ -f /tmp/.buildx-cache-new ] + # then { + # mv /tmp/.buildx-cache-new /tmp/.buildx-cache + # } + # fi diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5731461 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +# Build arguments +ARG SOURCE_IMAGE_NAME=julia +ARG SOURCE_IMAGE_TAG=1.10-bookworm + +FROM ${SOURCE_IMAGE_NAME}:${SOURCE_IMAGE_TAG} + +ARG DESTINATION_IMAGE_NAME=julia-vscode +ARG DESTINATION_IMAGE_TAG=1.10-bookworm + +# Set image metadata +LABEL org.opencontainers.image.licenses="GPL-2.0-or-later" \ + org.opencontainers.image.source="https://github.com/insightsengineering/julia-images" \ + org.opencontainers.image.vendor="Insights Engineering" \ + org.opencontainers.image.authors="Insights Engineering " + +ENV DEBIAN_FRONTEND=noninteractive \ + SHELL=/bin/bash \ + PATH=$PATH:/usr/local/julia + +WORKDIR /workspace + +# Copy installation scripts +COPY --chmod=0755 [\ + "scripts/install_sysdeps.sh", \ + "./"\ +] + +RUN ./install_sysdeps.sh ${DESTINATION_IMAGE_NAME} + +COPY --chmod=0755 init /init +COPY config/vs-code-config.yaml /root/.config/code-server/config.yaml + +WORKDIR / + +EXPOSE 8081 + +ENTRYPOINT ["/init"] diff --git a/init b/init new file mode 100644 index 0000000..ca14863 --- /dev/null +++ b/init @@ -0,0 +1,14 @@ +#!/usr/bin/bash + +echo "Start Visual Studio Code server" +code-server \ + --bind-addr 0.0.0.0:8081 \ + --auth none \ + --proxy-domain vscode \ + --user-data-dir ~/ \ + --extensions-dir /tmp/codeserver-extensions \ + --disable-update-check \ + --disable-telemetry \ + & + +sleep infinity diff --git a/scripts/install_sysdeps.sh b/scripts/install_sysdeps.sh new file mode 100644 index 0000000..a2d9075 --- /dev/null +++ b/scripts/install_sysdeps.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -e + +# Takes in the distribution as the first argument. +distribution="$1" + +echo "Distribution = $distribution" + +mkdir /root/.config +apt-get update +apt-get install -y sudo git wget htop +apt-get clean +apt-get autoremove -y +rm -rf /var/lib/apt/lists/* +echo "DEBIAN_FRONTEND=$DEBIAN_FRONTEND" >> /etc/profile +echo "LC_ALL=$LC_ALL" >> /etc/profile +echo "PATH=$PATH" >> /etc/profile + +if [ "$distribution" == "julia-vscode" ]; then + # Install VS Code server. + wget --no-check-certificate https://code-server.dev/install.sh -O - | sh +fi From d6c4f40d68a517a25d2a5bef20d8b6aacb2e6f69 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Wed, 20 Mar 2024 17:14:22 +0100 Subject: [PATCH 02/31] Update --- .github/workflows/deploy.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 7b43160..dccaa72 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -7,6 +7,9 @@ env: PLATFORMS: linux/amd64 on: + push: + branches: + - add-julia-docker-image # repository_dispatch: # types: # - scheduled From 9daa4888a001673a7f050667c2b1c119df9670c5 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Wed, 20 Mar 2024 17:15:53 +0100 Subject: [PATCH 03/31] Update --- .github/workflows/deploy.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index dccaa72..7b43160 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -7,9 +7,6 @@ env: PLATFORMS: linux/amd64 on: - push: - branches: - - add-julia-docker-image # repository_dispatch: # types: # - scheduled From d6fe4012eafd54f723eb91a8536922dc0865c971 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Wed, 20 Mar 2024 17:23:43 +0100 Subject: [PATCH 04/31] Update --- .github/workflows/deploy.yaml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 7b43160..69cf2b0 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -2,11 +2,14 @@ name: Deploy image to GHCR ๐Ÿช‚ env: REGISTRY: ghcr.io - # PLATFORMs is a comma-separted list of architectures to build for. + # PLATFORMS is a comma-separted list of architectures to build for. # We disable linux/arm64 due to runner mem saturation. PLATFORMS: linux/amd64 on: + push: + branches: + - add-julia-docker-image # repository_dispatch: # types: # - scheduled @@ -81,13 +84,23 @@ jobs: fi echo ${var} } - ORIGIN=$(normalize ${{ github.event.inputs.origin }} ${{ github.event.client_payload.origin }}) - SOURCE_IMAGE_TAG=$(normalize ${{ github.event.inputs.source_image_tag }} ${{ github.event.client_payload.source_image_tag }}) - DESTINATION_IMAGE_NAME=$(normalize ${{ github.event.inputs.destination_image_name }} ${{ github.event.client_payload.destination_image_name }}) - DESTINATION_IMAGE_TAG=$(normalize ${{ github.event.inputs.destination_image_tag }} ${{ github.event.client_payload.destination_image_tag }}) + + # TODO Remove once the workflow appears on main. + ORIGIN=$(normalize ${{ github.event.inputs.origin }} julia) + SOURCE_IMAGE_TAG=$(normalize ${{ github.event.inputs.source_image_tag }} 1.10-bookworm) + DESTINATION_IMAGE_NAME=$(normalize ${{ github.event.inputs.destination_image_name }} julia-vscode) + DESTINATION_IMAGE_TAG=$(normalize ${{ github.event.inputs.destination_image_tag }} 1.10-bookworm) + + # TODO uncomment once this is merged to main. + # ORIGIN=$(normalize ${{ github.event.inputs.origin }} ${{ github.event.client_payload.origin }}) + # SOURCE_IMAGE_TAG=$(normalize ${{ github.event.inputs.source_image_tag }} ${{ github.event.client_payload.source_image_tag }}) + # DESTINATION_IMAGE_NAME=$(normalize ${{ github.event.inputs.destination_image_name }} ${{ github.event.client_payload.destination_image_name }}) + # DESTINATION_IMAGE_TAG=$(normalize ${{ github.event.inputs.destination_image_tag }} ${{ github.event.client_payload.destination_image_tag }}) + TAG=$(normalize ${{ github.event.inputs.tag }} ${{ github.event.client_payload.tag }}) TAG_LATEST=$(normalize ${{ github.event.inputs.tag_latest }} ${{ github.event.client_payload.tag_latest }}) RELEASE_TAG=$(normalize ${{ github.event.inputs.release_tag }} ${{ github.event.client_payload.release_tag }}) + echo "ORIGIN=$ORIGIN" >> $GITHUB_OUTPUT echo "SOURCE_IMAGE_TAG=$SOURCE_IMAGE_TAG" >> $GITHUB_OUTPUT echo "DESTINATION_IMAGE_NAME=$DESTINATION_IMAGE_NAME" >> $GITHUB_OUTPUT From f4f41126ffc56912ea17f79cb06d294e36e7d20c Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Wed, 20 Mar 2024 17:29:46 +0100 Subject: [PATCH 05/31] Update --- config/vs-code-config.yaml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 config/vs-code-config.yaml diff --git a/config/vs-code-config.yaml b/config/vs-code-config.yaml new file mode 100644 index 0000000..9fd32a9 --- /dev/null +++ b/config/vs-code-config.yaml @@ -0,0 +1,4 @@ +bind-addr: 0.0.0.0:8081 +auth: none +password: +cert: false From e23fc4dd34fd925b741544a51ae34429f9ff5190 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Mon, 25 Mar 2024 12:16:21 +0100 Subject: [PATCH 06/31] Update --- .github/workflows/deploy.yaml | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 69cf2b0..00e7343 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -39,21 +39,16 @@ on: options: - "julia-vscode" - destination_image_tag: - description: Destination image tag + tag: + description: | + Custom Image Tag/Version. Defaults to current date in the `YYYY.MM.DD` + format if unspecified. required: true type: choice default: "1.10-bookworm" options: - "1.10-bookworm" - tag: - description: | - Custom Image Tag/Version. Defaults to current date in the `YYYY.MM.DD` - format if unspecified. - required: false - default: "" - tag_latest: description: Tag image as `latest` default: false @@ -89,13 +84,11 @@ jobs: ORIGIN=$(normalize ${{ github.event.inputs.origin }} julia) SOURCE_IMAGE_TAG=$(normalize ${{ github.event.inputs.source_image_tag }} 1.10-bookworm) DESTINATION_IMAGE_NAME=$(normalize ${{ github.event.inputs.destination_image_name }} julia-vscode) - DESTINATION_IMAGE_TAG=$(normalize ${{ github.event.inputs.destination_image_tag }} 1.10-bookworm) # TODO uncomment once this is merged to main. # ORIGIN=$(normalize ${{ github.event.inputs.origin }} ${{ github.event.client_payload.origin }}) # SOURCE_IMAGE_TAG=$(normalize ${{ github.event.inputs.source_image_tag }} ${{ github.event.client_payload.source_image_tag }}) # DESTINATION_IMAGE_NAME=$(normalize ${{ github.event.inputs.destination_image_name }} ${{ github.event.client_payload.destination_image_name }}) - # DESTINATION_IMAGE_TAG=$(normalize ${{ github.event.inputs.destination_image_tag }} ${{ github.event.client_payload.destination_image_tag }}) TAG=$(normalize ${{ github.event.inputs.tag }} ${{ github.event.client_payload.tag }}) TAG_LATEST=$(normalize ${{ github.event.inputs.tag_latest }} ${{ github.event.client_payload.tag_latest }}) @@ -104,7 +97,6 @@ jobs: echo "ORIGIN=$ORIGIN" >> $GITHUB_OUTPUT echo "SOURCE_IMAGE_TAG=$SOURCE_IMAGE_TAG" >> $GITHUB_OUTPUT echo "DESTINATION_IMAGE_NAME=$DESTINATION_IMAGE_NAME" >> $GITHUB_OUTPUT - echo "DESTINATION_IMAGE_TAG=$DESTINATION_IMAGE_TAG" >> $GITHUB_OUTPUT echo "TAG=$TAG" >> $GITHUB_OUTPUT echo "TAG_LATEST=$TAG_LATEST" >> $GITHUB_OUTPUT echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_OUTPUT @@ -113,7 +105,6 @@ jobs: origin: ${{ steps.normalizer.outputs.ORIGIN }} source_image_tag: ${{ steps.normalizer.outputs.SOURCE_IMAGE_TAG }} destination_image_name: ${{ steps.normalizer.outputs.DESTINATION_IMAGE_NAME }} - destination_image_tag: ${{ steps.normalizer.outputs.DESTINATION_IMAGE_TAG }} tag: ${{ steps.normalizer.outputs.TAG }} tag_latest: ${{ steps.normalizer.outputs.TAG_LATEST }} release_tag: ${{ steps.normalizer.outputs.RELEASE_TAG }} @@ -186,7 +177,6 @@ jobs: tag_latest="${{ needs.normalize-inputs.outputs.tag_latest }}" image_name="${{ needs.normalize-inputs.outputs.destination_image_name }} - image_tag="${{ needs.normalize-inputs.outputs.destination_image_tag }} # Set full image name full_names="${{ env.REGISTRY }}/${{ github.repository_owner }}/${image_name}:${tag}" @@ -223,7 +213,7 @@ jobs: ORIGIN=${{ needs.normalize-inputs.outputs.origin }} SOURCE_IMAGE_TAG=${{ needs.normalize-inputs.outputs.source_image_tag }} DESTINATION_IMAGE_NAME=${{ needs.normalize-inputs.outputs.destination_image_name }} - DESTINATION_IMAGE_TAG=${{ needs.normalize-inputs.outputs.destination_image_tag }} + DESTINATION_IMAGE_TAG=${{ needs.normalize-inputs.outputs.tag }} platforms: ${{ env.PLATFORMS }} - name: Generate image manifest ๐Ÿณ From 08522de9f27a25e3b2c8fddae52b43f5673a2315 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Mon, 25 Mar 2024 12:30:58 +0100 Subject: [PATCH 07/31] Update --- .github/workflows/deploy.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 00e7343..aefd070 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -84,13 +84,14 @@ jobs: ORIGIN=$(normalize ${{ github.event.inputs.origin }} julia) SOURCE_IMAGE_TAG=$(normalize ${{ github.event.inputs.source_image_tag }} 1.10-bookworm) DESTINATION_IMAGE_NAME=$(normalize ${{ github.event.inputs.destination_image_name }} julia-vscode) + TAG=$(normalize ${{ github.event.inputs.tag }} 1.10-bookworm) # TODO uncomment once this is merged to main. # ORIGIN=$(normalize ${{ github.event.inputs.origin }} ${{ github.event.client_payload.origin }}) # SOURCE_IMAGE_TAG=$(normalize ${{ github.event.inputs.source_image_tag }} ${{ github.event.client_payload.source_image_tag }}) # DESTINATION_IMAGE_NAME=$(normalize ${{ github.event.inputs.destination_image_name }} ${{ github.event.client_payload.destination_image_name }}) + # TAG=$(normalize ${{ github.event.inputs.tag }} ${{ github.event.client_payload.tag }}) - TAG=$(normalize ${{ github.event.inputs.tag }} ${{ github.event.client_payload.tag }}) TAG_LATEST=$(normalize ${{ github.event.inputs.tag_latest }} ${{ github.event.client_payload.tag_latest }}) RELEASE_TAG=$(normalize ${{ github.event.inputs.release_tag }} ${{ github.event.client_payload.release_tag }}) From b99e7933f9d00c07fabcc2e9098d57fa4efe1126 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Mon, 25 Mar 2024 12:36:43 +0100 Subject: [PATCH 08/31] Update --- .github/workflows/deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index aefd070..a4e52f3 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -177,7 +177,7 @@ jobs: fi tag_latest="${{ needs.normalize-inputs.outputs.tag_latest }}" - image_name="${{ needs.normalize-inputs.outputs.destination_image_name }} + image_name="${{ needs.normalize-inputs.outputs.destination_image_name }}" # Set full image name full_names="${{ env.REGISTRY }}/${{ github.repository_owner }}/${image_name}:${tag}" From 939356609ebc8f71fb46ebcf4a79a7efc54ee9bb Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Mon, 25 Mar 2024 14:06:45 +0100 Subject: [PATCH 09/31] Update --- .github/workflows/deploy.yaml | 5 ++++ scripts/install_sysdeps.sh | 55 ++++++++++++++++++++++++++++------- 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index a4e52f3..fba53e9 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -38,6 +38,7 @@ on: default: "julia-vscode" options: - "julia-vscode" + - "julia" tag: description: | @@ -191,6 +192,10 @@ jobs: # Push the image if we're running for main echo "github.ref = ${{ github.ref }}" + + # TODO remove the line below + echo "DOCKER_PUSH=true" >> $GITHUB_OUTPUT + if [ "${{ github.ref }}" == 'refs/heads/main' ]; then echo "DOCKER_PUSH=true" >> $GITHUB_OUTPUT echo "DOCKER_PUSH = true" diff --git a/scripts/install_sysdeps.sh b/scripts/install_sysdeps.sh index a2d9075..6107dcd 100644 --- a/scripts/install_sysdeps.sh +++ b/scripts/install_sysdeps.sh @@ -2,22 +2,55 @@ set -e -# Takes in the distribution as the first argument. -distribution="$1" +# Takes in the destination image name as the first argument. +destination_image_name="$1" -echo "Distribution = $distribution" +echo "DESTINATION_IMAGE_NAME = $destination_image_name" + +declare -A pkgs_to_install + +shared_deps="\ +wget \ +" + +pkgs_to_install["julia"]="${shared_deps}" + +pkgs_to_install["julia-vscode"]="${shared_deps} \ +curl \ +ssh \ +git \ +vim \ +less \ +nano \ +" mkdir /root/.config -apt-get update -apt-get install -y sudo git wget htop -apt-get clean -apt-get autoremove -y -rm -rf /var/lib/apt/lists/* -echo "DEBIAN_FRONTEND=$DEBIAN_FRONTEND" >> /etc/profile -echo "LC_ALL=$LC_ALL" >> /etc/profile -echo "PATH=$PATH" >> /etc/profile + +export DEBIAN_FRONTEND=noninteractive +export ACCEPT_EULA=Y +apt-get update -y +apt-get install -y -q ${shared_deps} +apt-get install -y ${pkgs_to_install["${destination_image_name}"]} + +# Install quarto +ARCH=$(dpkg --print-architecture) +QUARTO_DL_URL=$(wget -qO- https://api.github.com/repos/quarto-dev/quarto-cli/releases/latest | grep -oP "(?<=\"browser_download_url\":\s\")https.*${ARCH}\.deb") +wget -q "${QUARTO_DL_URL}" -O quarto-"${ARCH}".deb +dpkg -i quarto-"${ARCH}".deb +quarto check install if [ "$distribution" == "julia-vscode" ]; then # Install VS Code server. wget --no-check-certificate https://code-server.dev/install.sh -O - | sh fi + +# Install security patches +unattended-upgrade -v + +# Clean up +apt-get autoremove -y +apt-get autoclean -y +rm -rf /var/lib/apt/lists/* quarto-"${ARCH}".deb + +echo "LC_ALL=$LC_ALL" >> /etc/profile +echo "PATH=$PATH" >> /etc/profile From 7b10461cb139bfb5e6c215075e3d355c1ff70b83 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Mon, 25 Mar 2024 14:14:04 +0100 Subject: [PATCH 10/31] Update --- scripts/install_sysdeps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install_sysdeps.sh b/scripts/install_sysdeps.sh index 6107dcd..406028a 100644 --- a/scripts/install_sysdeps.sh +++ b/scripts/install_sysdeps.sh @@ -11,6 +11,7 @@ declare -A pkgs_to_install shared_deps="\ wget \ +unattended-upgrades \ " pkgs_to_install["julia"]="${shared_deps}" From 1b1c401b3360d6738761ae076a6d7a0186895922 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Mon, 25 Mar 2024 14:24:52 +0100 Subject: [PATCH 11/31] Update --- .github/workflows/deploy.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index fba53e9..2eb464a 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -193,9 +193,6 @@ jobs: # Push the image if we're running for main echo "github.ref = ${{ github.ref }}" - # TODO remove the line below - echo "DOCKER_PUSH=true" >> $GITHUB_OUTPUT - if [ "${{ github.ref }}" == 'refs/heads/main' ]; then echo "DOCKER_PUSH=true" >> $GITHUB_OUTPUT echo "DOCKER_PUSH = true" @@ -204,6 +201,10 @@ jobs: echo "DOCKER_PUSH = false" fi + # TODO remove + echo "DOCKER_PUSH = true" + echo "DOCKER_PUSH=true" >> $GITHUB_OUTPUT + echo "SBOM_OUTPUT_FILENAME=$GITHUB_WORKSPACE/sbom.json" >> $GITHUB_OUTPUT - name: Build and push image ๐Ÿ— From d4849617d5490a222eb84965f397be3038615302 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 26 Mar 2024 11:18:02 +0100 Subject: [PATCH 12/31] Empty From 6c6ebb3340e51ff4ffad0b899b94fd09e537ebbd Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 26 Mar 2024 11:34:12 +0100 Subject: [PATCH 13/31] Update --- .github/workflows/deploy.yaml | 92 +++++++++++++++++------------------ Dockerfile | 2 +- init => init-vscode | 2 +- scripts/install_sysdeps.sh | 11 ++++- 4 files changed, 58 insertions(+), 49 deletions(-) rename init => init-vscode (86%) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 2eb464a..408711a 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -227,49 +227,49 @@ jobs: run: | docker manifest inspect ${{ steps.build_vars.outputs.OUTPUT_IMAGE_NAME }} > manifest.json - # - name: Reclaim Disk Space for SBOM Generation ๐Ÿšฎ - # uses: insightsengineering/disk-space-reclaimer@v1 - # with: - # tools-cache: false - # android: true - # dotnet: true - # haskell: true - # large-packages: true - # swap-storage: false - # docker-images: true - - # - name: Generate SBOM ๐Ÿ“ƒ - # uses: anchore/sbom-action@v0 - # with: - # image: "${{ steps.build_vars.outputs.OUTPUT_IMAGE_NAME }}" - # output-file: "${{ steps.build_vars.outputs.SBOM_OUTPUT_FILENAME }}" - # artifact-name: "sbom.spdx" - - # - name: Upload image manifest to release ๐Ÿ”ผ - # uses: svenstaro/upload-release-action@v2 - # if: "${{ needs.normalize-inputs.outputs.release_tag }} != ''" - # with: - # repo_token: ${{ secrets.REPO_GITHUB_TOKEN }} - # file: "manifest.json" - # asset_name: "image.manifest.${{ steps.build_vars.outputs.OUTPUT_IMAGE_NAME }}.json" - # tag: "${{ needs.normalize-inputs.outputs.release_tag }}" - # overwrite: true - - # - name: Upload SBOM to release ๐Ÿ”ผ - # uses: svenstaro/upload-release-action@v2 - # if: "${{ needs.normalize-inputs.outputs.release_tag }} != ''" - # with: - # repo_token: ${{ secrets.REPO_GITHUB_TOKEN }} - # file: "${{ steps.build_vars.outputs.SBOM_OUTPUT_FILENAME }}" - # asset_name: "SBOM for ${{ steps.build_vars.outputs.OUTPUT_IMAGE_NAME }}.spdx.json" - # tag: "${{ needs.normalize-inputs.outputs.release_tag }}" - # overwrite: true - - # - name: Move cache โ™ป๏ธ - # run: | - # rm -rf /tmp/.buildx-cache - # if [ -f /tmp/.buildx-cache-new ] - # then { - # mv /tmp/.buildx-cache-new /tmp/.buildx-cache - # } - # fi + - name: Reclaim Disk Space for SBOM Generation ๐Ÿšฎ + uses: insightsengineering/disk-space-reclaimer@v1 + with: + tools-cache: false + android: true + dotnet: true + haskell: true + large-packages: true + swap-storage: false + docker-images: true + + - name: Generate SBOM ๐Ÿ“ƒ + uses: anchore/sbom-action@v0 + with: + image: "${{ steps.build_vars.outputs.OUTPUT_IMAGE_NAME }}" + output-file: "${{ steps.build_vars.outputs.SBOM_OUTPUT_FILENAME }}" + artifact-name: "sbom.spdx" + + - name: Upload image manifest to release ๐Ÿ”ผ + uses: svenstaro/upload-release-action@v2 + if: "${{ needs.normalize-inputs.outputs.release_tag }} != ''" + with: + repo_token: ${{ secrets.REPO_GITHUB_TOKEN }} + file: "manifest.json" + asset_name: "image.manifest.${{ steps.build_vars.outputs.OUTPUT_IMAGE_NAME }}.json" + tag: "${{ needs.normalize-inputs.outputs.release_tag }}" + overwrite: true + + - name: Upload SBOM to release ๐Ÿ”ผ + uses: svenstaro/upload-release-action@v2 + if: "${{ needs.normalize-inputs.outputs.release_tag }} != ''" + with: + repo_token: ${{ secrets.REPO_GITHUB_TOKEN }} + file: "${{ steps.build_vars.outputs.SBOM_OUTPUT_FILENAME }}" + asset_name: "SBOM for ${{ steps.build_vars.outputs.OUTPUT_IMAGE_NAME }}.spdx.json" + tag: "${{ needs.normalize-inputs.outputs.release_tag }}" + overwrite: true + + - name: Move cache โ™ป๏ธ + run: | + rm -rf /tmp/.buildx-cache + if [ -f /tmp/.buildx-cache-new ] + then { + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + } + fi diff --git a/Dockerfile b/Dockerfile index 5731461..a14fcef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,7 @@ COPY --chmod=0755 [\ RUN ./install_sysdeps.sh ${DESTINATION_IMAGE_NAME} -COPY --chmod=0755 init /init +COPY --chmod=0755 init-vscode /init-vscode COPY config/vs-code-config.yaml /root/.config/code-server/config.yaml WORKDIR / diff --git a/init b/init-vscode similarity index 86% rename from init rename to init-vscode index ca14863..1670df0 100644 --- a/init +++ b/init-vscode @@ -1,6 +1,6 @@ #!/usr/bin/bash -echo "Start Visual Studio Code server" +echo "Starting Visual Studio Code server" code-server \ --bind-addr 0.0.0.0:8081 \ --auth none \ diff --git a/scripts/install_sysdeps.sh b/scripts/install_sysdeps.sh index 406028a..9f16cf2 100644 --- a/scripts/install_sysdeps.sh +++ b/scripts/install_sysdeps.sh @@ -40,9 +40,10 @@ wget -q "${QUARTO_DL_URL}" -O quarto-"${ARCH}".deb dpkg -i quarto-"${ARCH}".deb quarto check install -if [ "$distribution" == "julia-vscode" ]; then +if [ "$destination_image_name" == "julia-vscode" ]; then # Install VS Code server. wget --no-check-certificate https://code-server.dev/install.sh -O - | sh + cp /init-vscode /init fi # Install security patches @@ -55,3 +56,11 @@ rm -rf /var/lib/apt/lists/* quarto-"${ARCH}".deb echo "LC_ALL=$LC_ALL" >> /etc/profile echo "PATH=$PATH" >> /etc/profile + +# Set default initializer if unavailable +if [ ! -f /init ] +then { + echo "sh" > /init + chmod +x /init +} +fi From bda68e766c6d1a83f66216883000f4b8386fabf1 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 26 Mar 2024 11:40:24 +0100 Subject: [PATCH 14/31] Update --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a14fcef..add6e08 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,11 +25,11 @@ COPY --chmod=0755 [\ "./"\ ] -RUN ./install_sysdeps.sh ${DESTINATION_IMAGE_NAME} - COPY --chmod=0755 init-vscode /init-vscode COPY config/vs-code-config.yaml /root/.config/code-server/config.yaml +RUN ./install_sysdeps.sh ${DESTINATION_IMAGE_NAME} + WORKDIR / EXPOSE 8081 From 38c4b4d50b49111e0f016fbf9a44e2dc5df069ff Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 26 Mar 2024 11:44:47 +0100 Subject: [PATCH 15/31] Update --- init-vscode | 3 --- scripts/install_sysdeps.sh | 2 -- 2 files changed, 5 deletions(-) diff --git a/init-vscode b/init-vscode index 1670df0..005e9ec 100644 --- a/init-vscode +++ b/init-vscode @@ -9,6 +9,3 @@ code-server \ --extensions-dir /tmp/codeserver-extensions \ --disable-update-check \ --disable-telemetry \ - & - -sleep infinity diff --git a/scripts/install_sysdeps.sh b/scripts/install_sysdeps.sh index 9f16cf2..2ddc724 100644 --- a/scripts/install_sysdeps.sh +++ b/scripts/install_sysdeps.sh @@ -25,8 +25,6 @@ less \ nano \ " -mkdir /root/.config - export DEBIAN_FRONTEND=noninteractive export ACCEPT_EULA=Y apt-get update -y From 3d110fe7e0e8298be8b304b44435b78156c99b70 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 26 Mar 2024 12:06:35 +0100 Subject: [PATCH 16/31] Update --- .github/workflows/deploy.yaml | 2 +- README.md | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 408711a..cddf121 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -61,7 +61,7 @@ on: Release tags follow the `YYYY.MM.DD` format. This must be specified if you want to upload artifacts to the release. required: false - default: "" + default: '' jobs: normalize-inputs: diff --git a/README.md b/README.md index e69de29..73f83c0 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,15 @@ +# julia-images + +To run the image with Julia and Visual Studio Code installed, execute: + +```shell +docker run -p 8081:8081 ghcr.io/insightsengineering/julia-vscode:1.10-bookworm +``` + +You can access Visual Studio code in your browser at `localhost:8081` + +To stop the container, run: + +```shell +docker stop $(docker ps | grep '0.0.0.0:8081' | awk '{print $1}') +``` From c3aec24b9bf287c8f6834015709b87baadcc0017 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 26 Mar 2024 12:18:19 +0100 Subject: [PATCH 17/31] Add scheduled workflow --- .github/workflows/deploy.yaml | 4 +- .github/workflows/scheduled.yaml | 65 ++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/scheduled.yaml diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index cddf121..6a68e4a 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -247,7 +247,7 @@ jobs: - name: Upload image manifest to release ๐Ÿ”ผ uses: svenstaro/upload-release-action@v2 - if: "${{ needs.normalize-inputs.outputs.release_tag }} != ''" + if: needs.normalize-inputs.outputs.release_tag != '' with: repo_token: ${{ secrets.REPO_GITHUB_TOKEN }} file: "manifest.json" @@ -257,7 +257,7 @@ jobs: - name: Upload SBOM to release ๐Ÿ”ผ uses: svenstaro/upload-release-action@v2 - if: "${{ needs.normalize-inputs.outputs.release_tag }} != ''" + if: needs.normalize-inputs.outputs.release_tag != '' with: repo_token: ${{ secrets.REPO_GITHUB_TOKEN }} file: "${{ steps.build_vars.outputs.SBOM_OUTPUT_FILENAME }}" diff --git a/.github/workflows/scheduled.yaml b/.github/workflows/scheduled.yaml new file mode 100644 index 0000000..08d61aa --- /dev/null +++ b/.github/workflows/scheduled.yaml @@ -0,0 +1,65 @@ +name: Scheduled Deployments โฒ + +on: + schedule: + - cron: '44 19 5,20 * *' + workflow_dispatch: + +jobs: + create-release: + name: Create release ๐ŸŒŸ + runs-on: ubuntu-latest + steps: + - name: Generate release body ๐Ÿ“œ + id: release-body + run: | + printf "Release $(date +"%Y.%m.%d")\n\n"\ + "You may view the artifacts in this release for more information "\ + "about the images that were published." > RELEASE_BODY.txt + echo "release-tag=$(date +"%Y.%m.%d")" >> $GITHUB_OUTPUT + + - name: Create release ๐ŸŒŸ + uses: softprops/action-gh-release@v1 + with: + body_path: RELEASE_BODY.txt + token: ${{ secrets.REPO_GITHUB_TOKEN }} + generate_release_notes: true + tag_name: ${{ steps.release-body.outputs.release-tag }} + + outputs: + release_tag: ${{ steps.release-body.outputs.release-tag }} + + build: + name: Build & Deploy ๐Ÿš€ + needs: create-release + runs-on: ubuntu-latest + strategy: + matrix: + image: + - source_image_tag: '1.10-bookworm' + destination_image_name: 'julia-vscode' + tag: '1.10-bookworm' + - source_image_tag: '1.10-bookworm' + destination_image_name: 'julia' + tag: '1.10-bookworm' + + # Trigger steps + steps: + - name: Checkout repository ๐Ÿ’ณ + uses: actions/checkout@v4 + with: + ref: main + + - name: Trigger all builds โ–ถ๏ธ + uses: peter-evans/repository-dispatch@v3 + with: + token: ${{ secrets.REPO_GITHUB_TOKEN }} + event-type: scheduled + client-payload: > + { + "source_image_tag": "${{ matrix.image.source_image_tag }}", + "destination_image_name": "${{ matrix.image.destination_image_name }}", + "tag": "${{ matrix.image.tag }}", + "tag_latest": "true", + "release_tag": "${{ needs.create-release.outputs.release_tag }}" + } From f70b907953baf998d5d0eff0a37490cc9e9db6ec Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 26 Mar 2024 12:27:27 +0100 Subject: [PATCH 18/31] Update --- .github/workflows/deploy.yaml | 8 +++++--- README.md | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 6a68e4a..4af96c4 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -32,7 +32,9 @@ on: - "1.10-bookworm" destination_image_name: - description: Destination image name + description: | + Destination image name, will be available as + ghcr.io/insightsengineering/destination_image_name required: true type: choice default: "julia-vscode" @@ -42,7 +44,7 @@ on: tag: description: | - Custom Image Tag/Version. Defaults to current date in the `YYYY.MM.DD` + Destination image tag. Defaults to current date in the `YYYY.MM.DD` format if unspecified. required: true type: choice @@ -114,7 +116,7 @@ jobs: build: runs-on: ubuntu-latest needs: normalize-inputs - name: Build & Deploy ๐Ÿš€ ${{ needs.normalize-inputs.outputs.destination_image_name }}:${{ needs.normalize-inputs.outputs.destination_image_tag }} + name: Build & Deploy ๐Ÿš€ ${{ needs.normalize-inputs.outputs.destination_image_name }}:${{ needs.normalize-inputs.outputs.tag }} # Token permissions permissions: diff --git a/README.md b/README.md index 73f83c0..f63d766 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ To run the image with Julia and Visual Studio Code installed, execute: ```shell -docker run -p 8081:8081 ghcr.io/insightsengineering/julia-vscode:1.10-bookworm +docker run -d -p 8081:8081 ghcr.io/insightsengineering/julia-vscode:1.10-bookworm ``` You can access Visual Studio code in your browser at `localhost:8081` From 59d861c3fd127a20b92feaee51774e71a2c2e556 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 26 Mar 2024 12:29:43 +0100 Subject: [PATCH 19/31] Update --- .github/workflows/deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 4af96c4..a94309f 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -86,7 +86,7 @@ jobs: # TODO Remove once the workflow appears on main. ORIGIN=$(normalize ${{ github.event.inputs.origin }} julia) SOURCE_IMAGE_TAG=$(normalize ${{ github.event.inputs.source_image_tag }} 1.10-bookworm) - DESTINATION_IMAGE_NAME=$(normalize ${{ github.event.inputs.destination_image_name }} julia-vscode) + DESTINATION_IMAGE_NAME=$(normalize ${{ github.event.inputs.destination_image_name }} julia) TAG=$(normalize ${{ github.event.inputs.tag }} 1.10-bookworm) # TODO uncomment once this is merged to main. From b449ac77b90d48a2dc311540c712651e47905b09 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 26 Mar 2024 12:54:36 +0100 Subject: [PATCH 20/31] Update --- README.md | 22 ++++++++++++++++++++++ scripts/install_sysdeps.sh | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f63d766..269d0bd 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,25 @@ To stop the container, run: ```shell docker stop $(docker ps | grep '0.0.0.0:8081' | awk '{print $1}') ``` + +To run the image with just Julia installed, execute: + +```shell +docker run -it --entrypoint julia ghcr.io/insightsengineering/julia:1.10-bookworm -e 'println("Hello, world!"); for x in ARGS; println(x); end' foo bar +``` + +To run an interactive Julia session, execute: + +```shell +docker run -it --entrypoint julia ghcr.io/insightsengineering/julia:1.10-bookworm +``` + +To run a shell in the Julia container, execute: + +```shell +$ docker run -it --entrypoint /bin/bash ghcr.io/insightsengineering/julia:1.10-bookworm +root@4913b172f781:/# julia --version +julia version 1.10.2 +root@4913b172f781:/# quarto --version +1.4.551 +``` diff --git a/scripts/install_sysdeps.sh b/scripts/install_sysdeps.sh index 2ddc724..ff7748f 100644 --- a/scripts/install_sysdeps.sh +++ b/scripts/install_sysdeps.sh @@ -58,7 +58,7 @@ echo "PATH=$PATH" >> /etc/profile # Set default initializer if unavailable if [ ! -f /init ] then { - echo "sh" > /init + echo "#!/bin/bash" > /init chmod +x /init } fi From a0233c8df24924756322b5541165256903f62d95 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 26 Mar 2024 13:10:43 +0100 Subject: [PATCH 21/31] Update --- scripts/install_sysdeps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install_sysdeps.sh b/scripts/install_sysdeps.sh index ff7748f..5e162ea 100644 --- a/scripts/install_sysdeps.sh +++ b/scripts/install_sysdeps.sh @@ -59,6 +59,7 @@ echo "PATH=$PATH" >> /etc/profile if [ ! -f /init ] then { echo "#!/bin/bash" > /init + echo "julia" >> /init chmod +x /init } fi From aee06f66faabde25960d0e01c307d26e7ab64f03 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 26 Mar 2024 13:20:03 +0100 Subject: [PATCH 22/31] Update --- scripts/install_sysdeps.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/scripts/install_sysdeps.sh b/scripts/install_sysdeps.sh index 5e162ea..f757f4a 100644 --- a/scripts/install_sysdeps.sh +++ b/scripts/install_sysdeps.sh @@ -54,12 +54,3 @@ rm -rf /var/lib/apt/lists/* quarto-"${ARCH}".deb echo "LC_ALL=$LC_ALL" >> /etc/profile echo "PATH=$PATH" >> /etc/profile - -# Set default initializer if unavailable -if [ ! -f /init ] -then { - echo "#!/bin/bash" > /init - echo "julia" >> /init - chmod +x /init -} -fi From 279596679f9ffc71eaf16b54b4f78ccfd277ff40 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 26 Mar 2024 13:25:49 +0100 Subject: [PATCH 23/31] Update --- scripts/install_sysdeps.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/install_sysdeps.sh b/scripts/install_sysdeps.sh index f757f4a..2ddc724 100644 --- a/scripts/install_sysdeps.sh +++ b/scripts/install_sysdeps.sh @@ -54,3 +54,11 @@ rm -rf /var/lib/apt/lists/* quarto-"${ARCH}".deb echo "LC_ALL=$LC_ALL" >> /etc/profile echo "PATH=$PATH" >> /etc/profile + +# Set default initializer if unavailable +if [ ! -f /init ] +then { + echo "sh" > /init + chmod +x /init +} +fi From f35f493637ed5f22338b95e226b4c9e8ebeff7c5 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 26 Mar 2024 13:34:02 +0100 Subject: [PATCH 24/31] Update --- scripts/install_sysdeps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/install_sysdeps.sh b/scripts/install_sysdeps.sh index 2ddc724..5e162ea 100644 --- a/scripts/install_sysdeps.sh +++ b/scripts/install_sysdeps.sh @@ -58,7 +58,8 @@ echo "PATH=$PATH" >> /etc/profile # Set default initializer if unavailable if [ ! -f /init ] then { - echo "sh" > /init + echo "#!/bin/bash" > /init + echo "julia" >> /init chmod +x /init } fi From c3cdcb545086ed93a23caa1b398494eed38c782a Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 26 Mar 2024 13:50:11 +0100 Subject: [PATCH 25/31] Update --- .github/workflows/deploy.yaml | 8 ++++---- README.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index a94309f..15fe335 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -2,17 +2,17 @@ name: Deploy image to GHCR ๐Ÿช‚ env: REGISTRY: ghcr.io - # PLATFORMS is a comma-separted list of architectures to build for. - # We disable linux/arm64 due to runner mem saturation. PLATFORMS: linux/amd64 on: + # TODO cleanup push: branches: - add-julia-docker-image # repository_dispatch: # types: # - scheduled + workflow_dispatch: inputs: origin: @@ -155,9 +155,9 @@ jobs: uses: actions/cache@v4 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ needs.normalize-inputs.outputs.destination_image_name }}-${{ needs.normalize-inputs.outputs.destination_image_tag }} + key: ${{ runner.os }}-buildx-${{ needs.normalize-inputs.outputs.destination_image_name }}-${{ needs.normalize-inputs.outputs.tag }} restore-keys: | - ${{ runner.os }}-buildx-${{ needs.normalize-inputs.outputs.destination_image_name }}-${{ needs.normalize-inputs.outputs.destination_image_tag }} + ${{ runner.os }}-buildx-${{ needs.normalize-inputs.outputs.destination_image_name }}-${{ needs.normalize-inputs.outputs.tag }} ${{ runner.os }}-buildx-${{ needs.normalize-inputs.outputs.destination_image_name }} ${{ runner.os }}-buildx- diff --git a/README.md b/README.md index 269d0bd..2841b2f 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ docker run -it --entrypoint julia ghcr.io/insightsengineering/julia:1.10-bookwor To run an interactive Julia session, execute: ```shell -docker run -it --entrypoint julia ghcr.io/insightsengineering/julia:1.10-bookworm +docker run -it ghcr.io/insightsengineering/julia:1.10-bookworm ``` To run a shell in the Julia container, execute: From ef781e070fd0da83d8dcfcd7e5234e35b1204959 Mon Sep 17 00:00:00 2001 From: walkowif <59475134+walkowif@users.noreply.github.com> Date: Tue, 26 Mar 2024 13:59:37 +0100 Subject: [PATCH 26/31] Update .github/workflows/scheduled.yaml Co-authored-by: cicdguy <26552821+cicdguy@users.noreply.github.com> Signed-off-by: walkowif <59475134+walkowif@users.noreply.github.com> --- .github/workflows/scheduled.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scheduled.yaml b/.github/workflows/scheduled.yaml index 08d61aa..e800008 100644 --- a/.github/workflows/scheduled.yaml +++ b/.github/workflows/scheduled.yaml @@ -2,7 +2,7 @@ name: Scheduled Deployments โฒ on: schedule: - - cron: '44 19 5,20 * *' + - cron: '44 19 10,25 * *' workflow_dispatch: jobs: From af7ddfd82d9fc1aa818facfe9fea7d276d1f6466 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Wed, 27 Mar 2024 10:28:59 +0100 Subject: [PATCH 27/31] Update --- .github/workflows/deploy.yaml | 6 +++--- Dockerfile | 4 ++++ scripts/install_apps.sh | 30 ++++++++++++++++++++++++++++++ scripts/install_julia_packages.sh | 29 +++++++++++++++++++++++++++++ scripts/install_sysdeps.sh | 22 ---------------------- 5 files changed, 66 insertions(+), 25 deletions(-) create mode 100644 scripts/install_apps.sh create mode 100644 scripts/install_julia_packages.sh diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 15fe335..0a56baa 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -86,7 +86,7 @@ jobs: # TODO Remove once the workflow appears on main. ORIGIN=$(normalize ${{ github.event.inputs.origin }} julia) SOURCE_IMAGE_TAG=$(normalize ${{ github.event.inputs.source_image_tag }} 1.10-bookworm) - DESTINATION_IMAGE_NAME=$(normalize ${{ github.event.inputs.destination_image_name }} julia) + DESTINATION_IMAGE_NAME=$(normalize ${{ github.event.inputs.destination_image_name }} julia-vscode) TAG=$(normalize ${{ github.event.inputs.tag }} 1.10-bookworm) # TODO uncomment once this is merged to main. @@ -139,13 +139,13 @@ jobs: - name: Checkout repository ๐Ÿ’ณ uses: actions/checkout@v4 - - name: Set up Docker Buildx + - name: Set up Docker Buildx ๐Ÿณ uses: docker/setup-buildx-action@v3 id: buildx with: install: true - - name: Set up QEMU + - name: Set up QEMU ๐Ÿฆค id: qemu uses: docker/setup-qemu-action@v3 with: diff --git a/Dockerfile b/Dockerfile index add6e08..6482420 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,8 @@ WORKDIR /workspace # Copy installation scripts COPY --chmod=0755 [\ "scripts/install_sysdeps.sh", \ + "scripts/install_apps.sh", \ + "scripts/install_julia_packages.sh", \ "./"\ ] @@ -29,6 +31,8 @@ COPY --chmod=0755 init-vscode /init-vscode COPY config/vs-code-config.yaml /root/.config/code-server/config.yaml RUN ./install_sysdeps.sh ${DESTINATION_IMAGE_NAME} +RUN ./install_apps.sh ${DESTINATION_IMAGE_NAME} +RUN ./install_julia_packages.sh ${DESTINATION_IMAGE_NAME} WORKDIR / diff --git a/scripts/install_apps.sh b/scripts/install_apps.sh new file mode 100644 index 0000000..3c523d1 --- /dev/null +++ b/scripts/install_apps.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -e + +# Takes in the destination image name as the first argument. +destination_image_name="$1" + +echo "DESTINATION_IMAGE_NAME = $destination_image_name" + +# Install quarto +ARCH=$(dpkg --print-architecture) +QUARTO_DL_URL=$(wget -qO- https://api.github.com/repos/quarto-dev/quarto-cli/releases/latest | grep -oP "(?<=\"browser_download_url\":\s\")https.*${ARCH}\.deb") +wget -q "${QUARTO_DL_URL}" -O quarto-"${ARCH}".deb +dpkg -i quarto-"${ARCH}".deb +quarto check install + +if [ "$destination_image_name" == "julia-vscode" ]; then + # Install VS Code server. + wget --no-check-certificate https://code-server.dev/install.sh -O - | sh + cp /init-vscode /init +fi + +# Set default initializer if unavailable +if [ ! -f /init ] +then { + echo "#!/bin/bash" > /init + echo "julia" >> /init + chmod +x /init +} +fi diff --git a/scripts/install_julia_packages.sh b/scripts/install_julia_packages.sh new file mode 100644 index 0000000..e9484a7 --- /dev/null +++ b/scripts/install_julia_packages.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -e + +# Takes in the destination image name as the first argument. +destination_image_name="$1" + +echo "DESTINATION_IMAGE_NAME = $destination_image_name" + +if [ "$destination_image_name" == "julia-vscode" ]; then +cat > install_pkgs.jl < install_pkgs.jl <> /etc/profile echo "PATH=$PATH" >> /etc/profile - -# Set default initializer if unavailable -if [ ! -f /init ] -then { - echo "#!/bin/bash" > /init - echo "julia" >> /init - chmod +x /init -} -fi From 4492efb3bdb9367042eb18a047b5df626bf5073f Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Thu, 28 Mar 2024 10:50:22 +0100 Subject: [PATCH 28/31] Install packages in Julia script --- Dockerfile | 4 ++-- scripts/install_julia_packages.sh | 29 ----------------------------- scripts/install_packages.jl | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 31 deletions(-) delete mode 100644 scripts/install_julia_packages.sh create mode 100644 scripts/install_packages.jl diff --git a/Dockerfile b/Dockerfile index 6482420..27fb8b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ WORKDIR /workspace COPY --chmod=0755 [\ "scripts/install_sysdeps.sh", \ "scripts/install_apps.sh", \ - "scripts/install_julia_packages.sh", \ + "scripts/install_packages.jl", \ "./"\ ] @@ -32,7 +32,7 @@ COPY config/vs-code-config.yaml /root/.config/code-server/config.yaml RUN ./install_sysdeps.sh ${DESTINATION_IMAGE_NAME} RUN ./install_apps.sh ${DESTINATION_IMAGE_NAME} -RUN ./install_julia_packages.sh ${DESTINATION_IMAGE_NAME} +RUN julia install_packages.jl ${DESTINATION_IMAGE_NAME} WORKDIR / diff --git a/scripts/install_julia_packages.sh b/scripts/install_julia_packages.sh deleted file mode 100644 index e9484a7..0000000 --- a/scripts/install_julia_packages.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# Takes in the destination image name as the first argument. -destination_image_name="$1" - -echo "DESTINATION_IMAGE_NAME = $destination_image_name" - -if [ "$destination_image_name" == "julia-vscode" ]; then -cat > install_pkgs.jl < install_pkgs.jl < Date: Thu, 28 Mar 2024 16:39:44 +0100 Subject: [PATCH 29/31] Install VS Code extensions --- init-vscode | 4 ++-- scripts/install_apps.sh | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/init-vscode b/init-vscode index 005e9ec..5d48db0 100644 --- a/init-vscode +++ b/init-vscode @@ -6,6 +6,6 @@ code-server \ --auth none \ --proxy-domain vscode \ --user-data-dir ~/ \ - --extensions-dir /tmp/codeserver-extensions \ + --extensions-dir /root/.local/share/code-server/extensions/ \ --disable-update-check \ - --disable-telemetry \ + --disable-telemetry diff --git a/scripts/install_apps.sh b/scripts/install_apps.sh index 3c523d1..0924fd4 100644 --- a/scripts/install_apps.sh +++ b/scripts/install_apps.sh @@ -7,6 +7,11 @@ destination_image_name="$1" echo "DESTINATION_IMAGE_NAME = $destination_image_name" +# List of VS Code Server extensions. +declare -a extension_list=( + "julialang.language-julia" +) + # Install quarto ARCH=$(dpkg --print-architecture) QUARTO_DL_URL=$(wget -qO- https://api.github.com/repos/quarto-dev/quarto-cli/releases/latest | grep -oP "(?<=\"browser_download_url\":\s\")https.*${ARCH}\.deb") @@ -16,7 +21,13 @@ quarto check install if [ "$destination_image_name" == "julia-vscode" ]; then # Install VS Code server. + echo "Installing Code Server..." wget --no-check-certificate https://code-server.dev/install.sh -O - | sh + echo "Installing Code Server extensions..." + for extension_name in "${extension_list[@]}" + do + code-server --install-extension $extension_name + done cp /init-vscode /init fi From 70ee5d1732dbf0e112f46014b441aa5071b20bed Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Wed, 3 Apr 2024 14:59:54 +0200 Subject: [PATCH 30/31] Add Plots package --- scripts/install_packages.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/install_packages.jl b/scripts/install_packages.jl index 6bc484f..874f1ba 100644 --- a/scripts/install_packages.jl +++ b/scripts/install_packages.jl @@ -8,7 +8,8 @@ if ARGS[1] == "julia-vscode" "CSV", "DataFrames", "JSON", - "BenchmarkTools" + "BenchmarkTools", + "Plots" ] elseif ARGS[1] == "julia" pkgs=[ @@ -16,7 +17,8 @@ elseif ARGS[1] == "julia" "CSV", "DataFrames", "JSON", - "BenchmarkTools" + "BenchmarkTools", + "Plots" ] else println("Unknown destination image name.") From a26d130aabe23936706b0240de4d7cc80ab022aa Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Wed, 3 Apr 2024 15:21:36 +0200 Subject: [PATCH 31/31] Cleanup --- .github/workflows/deploy.yaml | 30 +++++++----------------------- README.md | 4 ++-- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 0a56baa..ce17706 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -5,13 +5,9 @@ env: PLATFORMS: linux/amd64 on: - # TODO cleanup - push: - branches: - - add-julia-docker-image - # repository_dispatch: - # types: - # - scheduled + repository_dispatch: + types: + - scheduled workflow_dispatch: inputs: @@ -83,18 +79,10 @@ jobs: echo ${var} } - # TODO Remove once the workflow appears on main. - ORIGIN=$(normalize ${{ github.event.inputs.origin }} julia) - SOURCE_IMAGE_TAG=$(normalize ${{ github.event.inputs.source_image_tag }} 1.10-bookworm) - DESTINATION_IMAGE_NAME=$(normalize ${{ github.event.inputs.destination_image_name }} julia-vscode) - TAG=$(normalize ${{ github.event.inputs.tag }} 1.10-bookworm) - - # TODO uncomment once this is merged to main. - # ORIGIN=$(normalize ${{ github.event.inputs.origin }} ${{ github.event.client_payload.origin }}) - # SOURCE_IMAGE_TAG=$(normalize ${{ github.event.inputs.source_image_tag }} ${{ github.event.client_payload.source_image_tag }}) - # DESTINATION_IMAGE_NAME=$(normalize ${{ github.event.inputs.destination_image_name }} ${{ github.event.client_payload.destination_image_name }}) - # TAG=$(normalize ${{ github.event.inputs.tag }} ${{ github.event.client_payload.tag }}) - + ORIGIN=$(normalize ${{ github.event.inputs.origin }} ${{ github.event.client_payload.origin }}) + SOURCE_IMAGE_TAG=$(normalize ${{ github.event.inputs.source_image_tag }} ${{ github.event.client_payload.source_image_tag }}) + DESTINATION_IMAGE_NAME=$(normalize ${{ github.event.inputs.destination_image_name }} ${{ github.event.client_payload.destination_image_name }}) + TAG=$(normalize ${{ github.event.inputs.tag }} ${{ github.event.client_payload.tag }}) TAG_LATEST=$(normalize ${{ github.event.inputs.tag_latest }} ${{ github.event.client_payload.tag_latest }}) RELEASE_TAG=$(normalize ${{ github.event.inputs.release_tag }} ${{ github.event.client_payload.release_tag }}) @@ -203,10 +191,6 @@ jobs: echo "DOCKER_PUSH = false" fi - # TODO remove - echo "DOCKER_PUSH = true" - echo "DOCKER_PUSH=true" >> $GITHUB_OUTPUT - echo "SBOM_OUTPUT_FILENAME=$GITHUB_WORKSPACE/sbom.json" >> $GITHUB_OUTPUT - name: Build and push image ๐Ÿ— diff --git a/README.md b/README.md index 2841b2f..bc7fd55 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,10 @@ To run the image with Julia and Visual Studio Code installed, execute: ```shell -docker run -d -p 8081:8081 ghcr.io/insightsengineering/julia-vscode:1.10-bookworm +docker run -d -p 8081:8081 -v $(pwd):/root/code ghcr.io/insightsengineering/julia-vscode:1.10-bookworm ``` -You can access Visual Studio code in your browser at `localhost:8081` +You can access Visual Studio code in your browser at `localhost:8081` and your current working directory will be available in `/root/code` in the container. To stop the container, run: