-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new version of the python image.
This new version is based on 22.04 and python3.10, and has an up to date version of all python packages. The versioning scheme is arbitrary major version, e.g. v1, v2, etc. The previous image is retained as v1, and the new image is v2. This move from maintaining 1 to 2 images requires some refactoring. Each major version has its own directory, and associated configuration files to track dependencies. They both share the same parameterised `Dockerfile` and `docker-compose.yaml`. In the process, I have also improved the local development tooling: - move from Makefile to parameterised justfile - some small reording of Dockerfile steps for efficiency and reuse - a proper solution for user the docker images themselves to add new dependencies and/or upgrade existing ones. This means you a) do not need all the python versions installed on your machine and b) this can be built on macos, in theory.
- Loading branch information
1 parent
42773f7
commit 552309c
Showing
16 changed files
with
864 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
services: | ||
# used to build the production image | ||
python: | ||
image: python | ||
base: | ||
init: true | ||
image: python:${MAJOR_VERSION}-base | ||
build: | ||
context: . | ||
target: python | ||
target: base-python | ||
cache_from: # should speed up the build in CI, where we have a cold cache | ||
- ghcr.io/opensafely-core/base-docker | ||
- ghcr.io/opensafely-core/python | ||
- ghcr.io/opensafely-core/base-action:${BASE} | ||
- ghcr.io/opensafely-core/python:${MAJOR_VERSION} | ||
args: | ||
# this makes the image work for later cache_from: usage | ||
- BUILDKIT_INLINE_CACHE=1 | ||
# env vars supplied by make/just | ||
- BUILD_NUMBER | ||
- BUILD_DATE | ||
- REVISION | ||
- VERSION | ||
init: true | ||
- BASE | ||
- MAJOR_VERSION | ||
|
||
python: | ||
extends: | ||
service: base | ||
image: python:${MAJOR_VERSION} | ||
build: | ||
target: python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
export DOCKER_BUILDKIT := "1" | ||
export BUILD_DATE := `date +'%y-%m-%dT%H:%M:%S.%3NZ'` | ||
export REVISION := `git rev-parse --short HEAD` | ||
|
||
# TODO: calculate this | ||
export BUILD_NUMBER := "1234" | ||
|
||
build version target="python" *args="": | ||
docker-compose --env-file {{ version }}/env build --pull {{ args }} {{ target }} | ||
|
||
test version *args="tests -v": | ||
docker-compose --env-file {{ version }}/env run --rm -v $PWD:/workspace python pytest {{ args }} | ||
|
||
update version *args="": | ||
docker-compose --env-file {{ version }}/env run --rm -v $PWD:/workspace base pip-compile {{ args }} {{ version }}/requirements.in -o {{ version }}/requirements.txt | ||
|
||
check: | ||
@docker pull hadolint/hadolint:v2.12.0 | ||
@docker run --rm -i hadolint/hadolint:v2.12.0 < Dockerfile | ||
|
||
publish version: | ||
#!/bin/bash | ||
set -euxo pipefail | ||
docker tag python:{{ version }} ghcr.io/opensafely-core/python:{{ version }} | ||
echo docker push ghcr.io/opensafely-core/python:{{ version }} | ||
|
||
if test "{{ version }}" = "v1"; then | ||
# jupyter is only alias for v1 | ||
docker tag python:{{ version }} ghcr.io/opensafely-core/jupyter:{{ version }} | ||
echo docker push ghcr.io/opensafely-core/jupyter:{{ version }} | ||
|
||
# v1 is also known as latest, at least until we transition fully | ||
docker tag python:{{ version }} ghcr.io/opensafely-core/python:latest | ||
docker tag python:{{ version }} ghcr.io/opensafely-core/jupyter:latest | ||
echo docker push ghcr.io/opensafely-core/python:latest | ||
echo docker push ghcr.io/opensafely-core/jupyter:latest | ||
fi | ||
|
||
|
||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
MAJOR_VERSION=v1 | ||
BASE=20.04 |
File renamed without changes.
Oops, something went wrong.