Skip to content

Commit c11abf1

Browse files
committed
Update for Mongo 8.2, optimize image pull
Include rapid release series 8.2 in addition to the stable 8.0 releases. For Mongo versions >= 8, remove the need for pulling Debian slim.
1 parent fa416d7 commit c11abf1

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

.github/workflows/docker-publish.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
# Build for multiple mongo versions
4444
strategy:
4545
matrix:
46-
mongo: [6, 7, 8]
46+
mongo: [6, 7, 8.0, 8.2]
4747

4848
steps:
4949
- name: Checkout repository
@@ -86,6 +86,15 @@ jobs:
8686
type=raw,value=mongo${{ matrix.mongo }}
8787
type=raw,value=latest,enable=${{ matrix.mongo == 7 }}
8888
89+
# For mongo versions >= 8, we can avoid pulling debian-slim when building
90+
# because Ubuntu noble is used as the base, which has qemu 8.2 in it.
91+
- name: Check mongo version to choose qemu source
92+
id: qemu_source_check
93+
uses: madhead/semver-utils@latest
94+
with:
95+
version: ${{ matrix.mongo }}
96+
satisfies: >=8
97+
8998
# Build and push Docker image with Buildx (don't push on PR)
9099
# https://github.com/docker/build-push-action
91100
- name: Build and push Docker image
@@ -94,7 +103,9 @@ jobs:
94103
with:
95104
context: .
96105
push: ${{ github.event_name != 'pull_request' }}
97-
build-args: mongo_tag=${{ matrix.mongo }}
106+
build-args: |
107+
mongo_tag=${{ matrix.mongo }}
108+
qemu_source=${{ steps.qemu_source_check.outputs.satisfies && format('{0}:{1}', 'mongo', matrix.mongo) || 'debian:stable-slim' }}
98109
tags: ${{ steps.meta.outputs.tags }}
99110
labels: ${{ steps.meta.outputs.labels }}
100111
cache-from: type=gha

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
# Specify a different source tag if you want with --build-arg mongo_tag=...
66
ARG mongo_tag=7.0
7+
ARG qemu_source=debian:stable-slim
78

8-
# Mongo builds use Ubuntu Jammy, and its version of qemu is too old to emulate
9+
# Mongo <= 7 builds use Ubuntu Jammy, and its version of qemu is too old to emulate
910
# AVX. However, the binaries are static, so it doesn't matter if we pull them
10-
# in from somewhere else. We'll use Debian slim
11-
FROM debian:stable-slim AS qemu
11+
# in from somewhere else. We'll use Debian slim in such cases, otherwise we'll
12+
# just re-use the Mongo 8+ image...
13+
FROM ${qemu_source} AS qemu
1214

1315
RUN apt-get update \
1416
&& apt-get -y install --no-install-recommends qemu-user-static

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ docker pull ghcr.io/stevekerrison/mongo-qemu-avx:mongo{mongo_version}
4141
Examples:
4242

4343
```
44-
docker pull ghcr.io/stevekerrison/mongo-qemu-avx:mongo8
44+
docker pull ghcr.io/stevekerrison/mongo-qemu-avx:mongo8.2
45+
docker pull ghcr.io/stevekerrison/mongo-qemu-avx:mongo8.0
4546
docker pull ghcr.io/stevekerrison/mongo-qemu-avx:mongo7
4647
docker pull ghcr.io/stevekerrison/mongo-qemu-avx:mongo6
4748
```
@@ -55,7 +56,7 @@ is idle for too long (60 days), then the scheduled GitHub Action is disabled.
5556

5657
If you want to build for yourself, here's how...
5758

58-
The Dockerfile uses Debian's `qemu-user-static` package to source
59+
The Dockerfile uses Debian/Ubuntu's `qemu-user-static` package to source
5960
`qemu-x86_64-static` and drop it into the modified `mongo` image. You don't
6061
need `qemu` installed on your host system when building.
6162

@@ -76,6 +77,21 @@ The default `mongo` version is `7.0` but you can specify the build arg
7677
docker build -t mongo-qemu:latest --build-arg mongo_tag=6.0 .
7778
```
7879

80+
##### Avoid using the Debian image to source `qemu`
81+
82+
If you want `mongo>=8` then its container is based on Ubuntu Noble,
83+
which has a sufficiently up to date `qemu` version. The build arg
84+
`qemu_source=mongo:${your mongo tag}` will still use two-stage
85+
building to install/copy `qemu`, but will do so using the same source
86+
image, saving you a pull:
87+
88+
```
89+
docker build -t mongo-qemu:latest \
90+
--build-arg mongo_tag=8.0 \
91+
--build-arg qemu_source=mongo:8.0
92+
```
93+
94+
7995
### How to use
8096

8197
Refer to the newly built container by tag, or incorporate it into your

0 commit comments

Comments
 (0)