Skip to content

Commit

Permalink
Build Docker images for Ubuntu 22.04 and 24.04 (#318)
Browse files Browse the repository at this point in the history
* Build Docker images for Ubuntu 22.04 and 24.04

* comment with question

* default to 24.04

* remove comment

* add JetBrains IDEs to gitignore

* update docker-run cmd

* change suffix to -ubuntu24.04

* review changes: refactor tagging

* whoops

* more tagging fixes
  • Loading branch information
joelberkeley authored Jan 11, 2025
1 parent 3fd992d commit 494967f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ jobs:
export DB_VERSION
echo "DB_VERSION=$DB_VERSION" >> "$GITHUB_ENV"
- name: Build Docker Image
- name: Build Docker Images
run: |
export NO_CACHE="${{ github.ref == 'refs/heads/main' }}"
DB="$DB_VERSION" make docker-build
UBUNTU_RELEASE=noble make docker-build
UBUNTU_RELEASE=jammy make docker-build
- name: Log in to registry
if: github.ref == 'refs/heads/main'
# This is where you will update the PAT to GITHUB_TOKEN
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image
- name: Push images
if: github.ref == 'refs/heads/main'
run: |
IMAGE_ID="ghcr.io/${{ github.repository_owner }}/idris2-pack"
Expand All @@ -47,6 +48,13 @@ jobs:
# Strip git ref prefix from version
echo IMAGE_ID="$IMAGE_ID"
echo DB_VERSION="$DB_VERSION"
docker tag "$IMAGE_ID:latest" "$IMAGE_ID:$DB_VERSION"
docker tag "$IMAGE_ID:jammy" "$IMAGE_ID:$DB_VERSION-jammy"
docker tag "$IMAGE_ID:noble" "$IMAGE_ID:$DB_VERSION-noble"
docker tag "$IMAGE_ID:noble" "$IMAGE_ID:$DB_VERSION"
docker tag "$IMAGE_ID:noble" "$IMAGE_ID:latest"
docker push "$IMAGE_ID:latest"
docker push "$IMAGE_ID:jammy"
docker push "$IMAGE_ID:noble"
docker push "$IMAGE_ID:$DB_VERSION"
docker push "$IMAGE_ID:$DB_VERSION-jammy"
docker push "$IMAGE_ID:$DB_VERSION-noble"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ build/
micropack/libidris2_support.so
micropack/libidris2_support.dylib
.vscode/
.idea/
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#checkov:skip=CKV_DOCKER_3: we intend to use `root` user

FROM ubuntu:22.04 AS build
ARG ubuntu_release

FROM ubuntu:$ubuntu_release AS build

SHELL ["/bin/bash", "-c"]

Expand All @@ -23,7 +25,7 @@ ENV SCHEME=chezscheme

RUN make micropack SCHEME=$SCHEME

FROM ubuntu:22.04
FROM ubuntu:$ubuntu_release

# hadolint ignore=DL3008,DL3015
RUN apt-get update && apt-get install --yes gcc make chezscheme libgmp3-dev git && rm -rf /var/lib/apt/lists/*
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export LD_LIBRARY_PATH = micropack
export DYLD_LIBRARY_PATH = micropack

DOCKER_IMAGE = ghcr.io/stefan-hoeck/idris2-pack
UBUNTU_RELEASE ?= noble
NO_CACHE ?= false

.PHONY: micropack
Expand All @@ -22,8 +23,8 @@ install-lib:

.PHONY: docker-build
docker-build:
docker build --no-cache=${NO_CACHE} -t ${DOCKER_IMAGE}:latest .
docker build --build-arg ubuntu_release=${UBUNTU_RELEASE} --no-cache=${NO_CACHE} -t ${DOCKER_IMAGE}:${UBUNTU_RELEASE} .

.PHONY: docker-run
docker-run:
docker run --rm -it ${DOCKER_IMAGE}:latest /bin/bash
docker run --rm -it ${DOCKER_IMAGE}:${UBUNTU_RELEASE} /bin/bash

0 comments on commit 494967f

Please sign in to comment.