Skip to content

Commit 07338fa

Browse files
Merge pull request #1183 from datajoint/docker-img-refactor
Refactor Docker image and package builds
2 parents 467990e + 618a8d5 commit 07338fa

19 files changed

+217
-303
lines changed

.devcontainer/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ RUN \
88
pip uninstall datajoint -y
99

1010
USER root
11-
ENV DJ_HOST fakeservices.datajoint.io
11+
ENV DJ_HOST db
1212
ENV DJ_USER root
1313
ENV DJ_PASS password

.devcontainer/devcontainer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
66
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
77
"dockerComposeFile": [
8-
"../LNX-docker-compose.yml",
8+
"../docker-compose.yaml",
99
"docker-compose.yml"
1010
],
1111
// The 'service' property is the name of the service for the container that VS Code should
@@ -28,7 +28,7 @@
2828
// "runServices": [],
2929
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
3030
"shutdownAction": "stopCompose",
31-
"onCreateCommand": "python3 -m pip install -e .",
31+
"onCreateCommand": "python3 -m pip install -q -e .[test]",
3232
"features": {
3333
"ghcr.io/devcontainers/features/git:1": {},
3434
"ghcr.io/devcontainers/features/docker-in-docker:2": {},

.github/workflows/development.yaml

+13-14
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ jobs:
2929
COMPOSE_HTTP_TIMEOUT: "120"
3030
steps:
3131
- uses: actions/checkout@v4
32+
- uses: actions/setup-python@v5
33+
with:
34+
python-version: ${{matrix.py_ver}}
3235
- name: Validate version and release notes
3336
run: |
3437
DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py)
35-
RELEASE_BODY=$(python -c \
38+
RELEASE_BODY=$(python3 -c \
3639
'print(open("./CHANGELOG.md").read().split("\n\n")[1].split("\n", 1)[1])' \
3740
)
3841
echo "DJ_VERSION=${DJ_VERSION}" >> $GITHUB_ENV
@@ -41,8 +44,8 @@ jobs:
4144
echo "EOF" >> $GITHUB_ENV
4245
- name: Build pip artifacts
4346
run: |
44-
export HOST_UID=$(id -u)
45-
docker compose -f docker-compose-build.yaml up --exit-code-from app --build
47+
python3 -m pip install build
48+
python3 -m build .
4649
echo "DJ_VERSION=${DJ_VERSION}" >> $GITHUB_ENV
4750
- if: matrix.py_ver == '3.9' && matrix.distro == 'debian'
4851
name: Add pip artifacts
@@ -58,6 +61,8 @@ jobs:
5861
py_ver: ["3.9"]
5962
mysql_ver: ["8.0", "5.7"]
6063
include:
64+
- py_ver: "3.12"
65+
mysql_ver: "8.0"
6166
- py_ver: "3.11"
6267
mysql_ver: "8.0"
6368
- py_ver: "3.10"
@@ -70,12 +75,6 @@ jobs:
7075
uses: actions/setup-python@v5
7176
with:
7277
python-version: ${{matrix.py_ver}}
73-
- name: Install dependencies
74-
run: |
75-
python -m pip install --upgrade pip
76-
pip install flake8 black
77-
- name: Run syntax tests
78-
run: flake8 datajoint --count --select=E9,F63,F7,F82 --show-source --statistics
7978
- name: Run primary tests
8079
env:
8180
PY_VER: ${{matrix.py_ver}}
@@ -87,7 +86,7 @@ jobs:
8786
COMPOSE_HTTP_TIMEOUT: "120"
8887
run: |
8988
export HOST_UID=$(id -u)
90-
docker compose -f LNX-docker-compose.yml up --build --exit-code-from app
89+
docker compose --profile test up --quiet-pull --build --exit-code-from djtest djtest
9190
lint:
9291
runs-on: ubuntu-latest
9392
strategy:
@@ -101,8 +100,8 @@ jobs:
101100
python-version: ${{matrix.py_ver}}
102101
- name: Install dependencies
103102
run: |
104-
python -m pip install --upgrade pip
105-
pip install flake8 black==24.2.0
103+
python3 -m pip install --upgrade pip
104+
python3 -m pip install ".[test]"
106105
- name: Run syntax tests
107106
run: flake8 datajoint --count --select=E9,F63,F7,F82 --show-source --statistics
108107
- name: Run style tests
@@ -138,7 +137,7 @@ jobs:
138137
export PACKAGE=datajoint
139138
export UPSTREAM_REPO=https://github.com/${GITHUB_REPOSITORY}.git
140139
export HOST_UID=$(id -u)
141-
docker compose -f docs/docker-compose.yaml up --exit-code-from docs --build
140+
docker compose -f docs/docker-compose.yaml up --quiet-pull --exit-code-from docs --build
142141
git push origin gh-pages
143142
publish-release:
144143
if: |
@@ -219,7 +218,7 @@ jobs:
219218
- name: Publish pip release
220219
run: |
221220
export HOST_UID=$(id -u)
222-
docker compose -f docker-compose-build.yaml run \
221+
docker compose run --build --quiet-pull \
223222
-e TWINE_USERNAME=${TWINE_USERNAME} -e TWINE_PASSWORD=${TWINE_PASSWORD} app \
224223
sh -c "pip install twine && python -m twine upload dist/*"
225224
- name: Login to DockerHub

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
## Release notes
22

3-
### 0.14.3 -- TBD
3+
### 0.14.3 -- Sep 20, 2024
44
- Added - `dj.Top` restriction ([#1024](https://github.com/datajoint/datajoint-python/issues/1024)) PR [#1084](https://github.com/datajoint/datajoint-python/pull/1084)
55
- Fixed - Added encapsulating double quotes to comply with [DOT language](https://graphviz.org/doc/info/lang.html) - PR [#1177](https://github.com/datajoint/datajoint-python/pull/1177)
66
- Added - Datajoint python CLI ([#940](https://github.com/datajoint/datajoint-python/issues/940)) PR [#1095](https://github.com/datajoint/datajoint-python/pull/1095)
77
- Added - Ability to set hidden attributes on a table - PR [#1091](https://github.com/datajoint/datajoint-python/pull/1091)
88
- Added - Ability to specify a list of keys to populate - PR [#989](https://github.com/datajoint/datajoint-python/pull/989)
99
- Fixed - fixed topological sort [#1057](https://github.com/datajoint/datajoint-python/issues/1057)- PR [#1184](https://github.com/datajoint/datajoint-python/pull/1184)
1010
- Fixed - .parts() not always returning parts [#1103](https://github.com/datajoint/datajoint-python/issues/1103)- PR [#1184](https://github.com/datajoint/datajoint-python/pull/1184)
11+
- Changed - replace `setup.py` with `pyproject.toml` PR [#1183](https://github.com/datajoint/datajoint-python/pull/1183)
1112

1213
### 0.14.2 -- Aug 19, 2024
1314
- Added - Migrate nosetests to pytest - PR [#1142](https://github.com/datajoint/datajoint-python/pull/1142)

Dockerfile

+21-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1-
ARG IMAGE=djbase
1+
ARG IMAGE=mambaorg/micromamba:1.5-bookworm-slim
2+
FROM ${IMAGE}
3+
4+
ARG CONDA_BIN=micromamba
25
ARG PY_VER=3.9
3-
ARG DISTRO=debian
4-
FROM datajoint/${IMAGE}:py${PY_VER}-${DISTRO}
5-
COPY --chown=anaconda:anaconda ./setup.py ./datajoint.pub ./requirements.txt /main/
6-
COPY --chown=anaconda:anaconda ./datajoint /main/datajoint
6+
ARG HOST_UID=1000
7+
8+
RUN ${CONDA_BIN} install --no-pin -qq -y -n base -c conda-forge \
9+
python=${PY_VER} pip setuptools git graphviz pydot && \
10+
${CONDA_BIN} clean -qq -afy
11+
ENV PATH="$PATH:/home/mambauser/.local/bin"
12+
13+
COPY --chown=${HOST_UID:-1000}:mambauser ./pyproject.toml ./README.md ./LICENSE.txt /main/
14+
COPY --chown=${HOST_UID:-1000}:mambauser ./datajoint /main/datajoint
15+
16+
VOLUME /src
17+
WORKDIR /src
18+
USER root
719
RUN \
8-
pip install --no-cache-dir /main && \
20+
chown -R ${HOST_UID:-1000}:mambauser /main && \
21+
chown -R ${HOST_UID:-1000}:mambauser /src && \
22+
${CONDA_BIN} run -n base pip install -q --no-cache-dir /main && \
923
rm -r /main/*
24+
USER ${MAMBA_USER}

LNX-docker-compose.yml

-101
This file was deleted.

MANIFEST.in

-1
This file was deleted.

datajoint/fetch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def __call__(
136136
format=None,
137137
as_dict=None,
138138
squeeze=False,
139-
download_path="."
139+
download_path=".",
140140
):
141141
"""
142142
Fetches the expression results from the database into an np.array or list of dictionaries and

datajoint/s3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(
2727
*,
2828
secure=False,
2929
proxy_server=None,
30-
**_
30+
**_,
3131
):
3232
# from https://docs.min.io/docs/python-client-api-reference
3333
self.client = minio.Minio(

docker-compose-build.yaml

-24
This file was deleted.

docker-compose.yaml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# HOST_UID=$(id -u) PY_VER=3.11 DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py) docker compose --profile test up --build --exit-code-from djtest djtest
2+
services:
3+
db:
4+
image: datajoint/mysql:${MYSQL_VER:-8.0}
5+
environment:
6+
- MYSQL_ROOT_PASSWORD=${DJ_PASS:-password}
7+
command: mysqld --default-authentication-plugin=mysql_native_password
8+
# ports:
9+
# - "3306:3306"
10+
# volumes:
11+
# - ./mysql/data:/var/lib/mysql
12+
healthcheck:
13+
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ]
14+
timeout: 30s
15+
retries: 5
16+
interval: 15s
17+
minio:
18+
image: minio/minio:${MINIO_VER:-RELEASE.2022-08-11T04-37-28Z}
19+
environment:
20+
- MINIO_ACCESS_KEY=datajoint
21+
- MINIO_SECRET_KEY=datajoint
22+
# ports:
23+
# - "9000:9000"
24+
# volumes:
25+
# - ./minio/config:/root/.minio
26+
# - ./minio/data:/data
27+
command: server --address ":9000" /data
28+
healthcheck:
29+
test:
30+
- "CMD"
31+
- "curl"
32+
- "--fail"
33+
- "http://minio:9000/minio/health/live"
34+
timeout: 30s
35+
retries: 5
36+
interval: 15s
37+
app:
38+
image: datajoint/datajoint:${DJ_VERSION:-latest}
39+
build:
40+
context: .
41+
dockerfile: Dockerfile
42+
args:
43+
PY_VER: ${PY_VER:-3.8}
44+
HOST_UID: ${HOST_UID:-1000}
45+
depends_on:
46+
db:
47+
condition: service_healthy
48+
minio:
49+
condition: service_healthy
50+
environment:
51+
- DJ_HOST=db
52+
- DJ_USER=root
53+
- DJ_PASS=password
54+
- DJ_TEST_HOST=db
55+
- DJ_TEST_USER=datajoint
56+
- DJ_TEST_PASSWORD=datajoint
57+
- S3_ENDPOINT=minio:9000
58+
- S3_ACCESS_KEY=datajoint
59+
- S3_SECRET_KEY=datajoint
60+
- S3_BUCKET=datajoint.test
61+
- PYTHON_USER=dja
62+
- JUPYTER_PASSWORD=datajoint
63+
working_dir: /src
64+
user: ${HOST_UID:-1000}:mambauser
65+
volumes:
66+
- .:/src
67+
djtest:
68+
extends:
69+
service: app
70+
profiles: ["test"]
71+
command:
72+
- sh
73+
- -c
74+
- |
75+
set -e
76+
pip install -q -e ".[test]"
77+
pip freeze | grep datajoint
78+
pytest --cov-report term-missing --cov=datajoint tests
79+

0 commit comments

Comments
 (0)