Skip to content

Commit

Permalink
Add devcontainer image and GH Action build
Browse files Browse the repository at this point in the history
To speed up devcontainer starts, build a partial image and use that as a base image for development
  • Loading branch information
oestoer committed Feb 11, 2024
1 parent 92f7149 commit b4555f3
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build-dev-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build Dev Container Base Image

on:
schedule:
- cron: '0 8 1 * *' # Scheduled at 08:00 on the first day of every month
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch: # Manually triggered

env:
CONTAINER_REGISTRY: ghcr.io
IMAGE_NAME: access-system-dev

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: 📦 Checkout code
uses: actions/checkout@v4

- name: 🏗️ Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID},sha=${GITHUB_SHA},ref=${GITHUB_REF}"

- name: 🔐 Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login $CONTAINER_REGISTRY -u $ --password-stdin

- name: 💾 Push image
run: |
IMAGE_ID=$CONTAINER_REGISTRY/$GITHUB_REPOSITORY_OWNER/$IMAGE_NAME
echo "Image ID: $IMAGE_ID"
echo "GITHUB_SHA: $GITHUB_SHA"
docker tag $IMAGE_NAME $IMAGE_ID:$GITHUB_SHA
docker push $IMAGE_ID:$GITHUB_SHA
VERSION=$(echo "$GITHUB_REF_NAME" | sed -e 's/[^a-zA-Z0-9]/-/g') # Get the branch name from the ref and replace non-alphanumeric characters with hyphens
[ "$VERSION" == "master" ] && VERSION=latest
echo "Version: $VERSION"
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
48 changes: 48 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

FROM mcr.microsoft.com/devcontainers/base:buster

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
perl=5.28.1-6+deb10u1 \
cpanminus \
libalgorithm-diff-perl \
libalgorithm-diff-xs-perl \
libalgorithm-merge-perl \
libcgi-fast-perl \
libcgi-pm-perl \
libclass-accessor-perl \
libclass-isa-perl \
libencode-locale-perl \
libfcgi-perl \
libfile-fcntllock-perl \
libhtml-parser-perl \
libhtml-tagset-perl \
libhttp-date-perl \
libhttp-message-perl \
libio-html-perl \
libio-string-perl \
liblocale-gettext-perl \
liblwp-mediatypes-perl \
libparse-debianchangelog-perl \
libsub-name-perl \
libswitch-perl \
libtext-charwidth-perl \
libtext-iconv-perl \
libtext-wrapi18n-perl \
libtimedate-perl \
liburi-perl \
libscalar-list-utils-perl \
&& cpanm -S Carton \
# for Perl::LanguageServer
&& apt-get -y install --no-install-recommends \
libanyevent-perl \
libclass-refresh-perl \
libdata-dump-perl \
libio-aio-perl \
libjson-perl \
libmoose-perl \
libpadwalker-perl \
libscalar-list-utils-perl \
libcoro-perl \
&& cpanm Perl::LanguageServer \
&& rm -rf /var/lib/apt/lists/*

0 comments on commit b4555f3

Please sign in to comment.