Skip to content

Commit

Permalink
Install module requirements before module in docker (#285)
Browse files Browse the repository at this point in the history
* Install module requirements before module in docker

* Update python to 3.11 in Dockerfiles

* Remove unused dockerfile
  • Loading branch information
stefpiatek authored Feb 9, 2024
1 parent 186e53f commit 511a00d
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 31 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ jobs:
python-version: 3.10.6
cache: "pip"

- name: Build test services
working-directory: test
run: |
docker compose build
- name: Build services
run: |
docker compose build
- name: Run tests
working-directory: test
run: |
Expand Down
9 changes: 8 additions & 1 deletion docker/ehr-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM python:3.10.6-slim-bullseye
FROM python:3.11.7-slim-bullseye
SHELL ["/bin/bash", "-o", "pipefail", "-e", "-u", "-x", "-c"]

ARG TEST="false"
Expand All @@ -25,6 +25,13 @@ RUN apt-get autoremove && apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install requirements before copying modules
COPY ./pixl_core/pyproject.toml ./pixl_core/pyproject.toml
COPY ./pixl_ehr/pyproject.toml ./pixl_ehr/pyproject.toml
RUN --mount=type=cache,target=/root/.cache \
pip3 install pixl_core/ \
&& pip3 install pixl_ehr/

COPY ./pixl_core/ core/
COPY ./pixl_ehr/ .
RUN --mount=type=cache,target=/root/.cache \
Expand Down
7 changes: 6 additions & 1 deletion docker/hasher-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM python:3.10.7-slim-bullseye
FROM python:3.11.7-slim-bullseye
SHELL ["/bin/bash", "-o", "pipefail", "-e", "-u", "-x", "-c"]

# OS setup
Expand All @@ -25,6 +25,11 @@ RUN sed -i '/en_GB.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
RUN apt-get autoremove && apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR /app
# Install requirements before copying modules
COPY ./hasher/pyproject.toml .
RUN --mount=type=cache,target=/root/.cache \
pip install /app/

COPY ./hasher/ .
RUN --mount=type=cache,target=/root/.cache \
pip install .
Expand Down
9 changes: 8 additions & 1 deletion docker/imaging-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM python:3.10.6-slim-bullseye
FROM python:3.11.7-slim-bullseye
SHELL ["/bin/bash", "-o", "pipefail", "-e", "-u", "-x", "-c"]

ARG TEST="false"
Expand All @@ -25,6 +25,13 @@ RUN apt-get autoremove && apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install requirements before copying modules
COPY ./pixl_core/pyproject.toml ./pixl_core/pyproject.toml
COPY ./pixl_imaging/pyproject.toml ./pixl_imaging/pyproject.toml
RUN --mount=type=cache,target=/root/.cache \
pip3 install pixl_core/ \
&& pip3 install pixl_imaging/

COPY ./pixl_core/ core/
COPY ./pixl_imaging/ .
RUN --mount=type=cache,target=/root/.cache \
Expand Down
13 changes: 11 additions & 2 deletions docker/orthanc-anon/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@
FROM osimis/orthanc:22.9.0-full-stable
SHELL ["/bin/bash", "-o", "pipefail", "-e", "-u", "-x", "-c"]

# Install requirements before copying modules
COPY ./pixl_core/pyproject.toml ./pixl_core/pyproject.toml
COPY ./pixl_dcmd/pyproject.toml ./pixl_dcmd/pyproject.toml
RUN --mount=type=cache,target=/root/.cache \
pip3 install pixl_core/ \
&& pip3 install pixl_dcmd/

COPY ./orthanc/orthanc-anon/plugin/pixl.py /etc/orthanc/pixl.py
COPY ./orthanc/orthanc-anon/plugin/tag-operations.yaml /etc/orthanc/tag-operations.yaml

COPY ./pixl_core/ ./pixl_core
RUN pip3 install --no-cache-dir ./pixl_core
RUN --mount=type=cache,target=/root/.cache \
pip3 install ./pixl_core

COPY ./pixl_dcmd/ ./pixl_dcmd
RUN pip3 install --no-cache-dir ./pixl_dcmd
RUN --mount=type=cache,target=/root/.cache \
pip3 install ./pixl_dcmd
14 changes: 11 additions & 3 deletions docker/postgres/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ COPY --chmod=0777 ./postgres/pixl-db_init.sh /docker-entrypoint-initdb.d/pixl-db

COPY --chmod=0777 ./postgres/create_pixl_tbls.py /pixl/create_pixl_tbls.py

# Install requirements before copying modules
COPY ./pixl_core/pyproject.toml /pixl/pixl_core/pyproject.toml
RUN --mount=type=cache,target=/root/.cache \
python3 -m venv /pixl/venv \
&& cd /pixl/venv/bin \
&& ./pip install /pixl/pixl_core/

WORKDIR /pixl/venv/bin

COPY ./pixl_core/ /pixl/pixl_core

RUN python3 -m venv /pixl/venv \
&& cd /pixl/venv/bin \
&& ./pip install /pixl/pixl_core/
RUN --mount=type=cache,target=/root/.cache \
./pip install /pixl/pixl_core/
19 changes: 0 additions & 19 deletions pixl_core/tests/Dockerfile

This file was deleted.

5 changes: 3 additions & 2 deletions test/Dockerfile.fake_emap_star
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ RUN if [ "$TAG" != "" ] ; then \
rm -rf /Satellite && \
git clone --depth 1 --branch ${TAG} https://github.com/UCLH-DIF/Satellite.git ;\
fi && \
pip install --no-cache-dir --upgrade pip==22.3.1
pip install --upgrade pip==22.3.1

WORKDIR /Satellite
RUN pip install --no-cache-dir . && \
RUN --mount=type=cache,target=/root/.cache \
pip install . && \
satellite print-db-create-command > /docker-entrypoint-initdb.d/create.sql && \
satellite print-create-command >> /docker-entrypoint-initdb.d/create.sql

Expand Down
5 changes: 3 additions & 2 deletions test/dummy-services/cogstack/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM python:3.10.6-slim-bullseye
FROM python:3.11.7-slim-bullseye

RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
Expand All @@ -23,6 +23,7 @@ WORKDIR /app
COPY cogstack.py .
COPY pyproject.toml .

RUN pip install -e .
RUN --mount=type=cache,target=/root/.cache \
pip install -e .

ENTRYPOINT ["uvicorn", "cogstack:app", "--host", "0.0.0.0", "--port", "8000"]

0 comments on commit 511a00d

Please sign in to comment.