|
1 | 1 | # Template build command |
2 | 2 | # podman build --build-arg groupid=<groupid> --build-arg userid=<userid> --build-arg groupname=<groupname> --no-cache -f path/to/Dockerfiles/murfey-server -t murfey-server:<version> path/to/python-murfey |
3 | 3 |
|
4 | | -# Set up the Python base image to build with |
| 4 | +# Set up the base image to build with |
5 | 5 | FROM docker.io/library/python:3.12.8-slim-bullseye AS base |
6 | 6 |
|
7 | | -# Define external build arguments |
8 | | -ARG groupid |
9 | | -ARG groupname |
10 | | -ARG userid |
| 7 | +# Install Vim in base image |
| 8 | +RUN apt-get update && \ |
| 9 | + apt-get upgrade -y && \ |
| 10 | + apt-get install -y --no-install-recommends \ |
| 11 | + vim \ |
| 12 | + && \ |
| 13 | + apt-get autoremove && \ |
| 14 | + rm -rf /var/lib/apt/lists/* |
11 | 15 |
|
12 | | -# Add system dependencies for the developer/build environment |
13 | | -# Add the group and user ID to be used by Murfey |
14 | | -# Create virtual Python environment in which to install Murfey |
15 | | -# Change properties of said Python environment |
| 16 | + |
| 17 | +# Build Murfey in a separate image |
| 18 | +FROM base as build |
| 19 | +COPY ./ /python-murfey/ |
16 | 20 | RUN apt-get update && \ |
17 | 21 | apt-get upgrade -y && \ |
18 | 22 | apt-get install -y --no-install-recommends \ |
19 | 23 | build-essential \ |
20 | 24 | busybox \ |
21 | 25 | git \ |
| 26 | + libpq-dev \ |
22 | 27 | net-tools \ |
23 | | - libpq-dev && \ |
| 28 | + && \ |
24 | 29 | busybox --install && \ |
25 | | - rm -rf /var/lib/apt/lists/* && \ |
26 | | - groupadd -r -g "${groupid}" "${groupname}" && \ |
27 | | - useradd -r -M "${groupname}" -u "${userid}" -g "${groupname}" && \ |
28 | 30 | python -m venv /venv && \ |
29 | | - chown -R "${userid}":"${groupid}" /venv && \ |
30 | | - chmod -R a+x /venv |
31 | | -ENV PATH=/venv/bin:$PATH |
32 | | - |
33 | | -# Build Murfey in a different image |
34 | | -# Change properties of the built Python environment |
35 | | -FROM base AS build |
36 | | -COPY --chown="${userid}":"${groupid}" ./ /python-murfey/ |
37 | | -RUN python -m pip install --upgrade \ |
| 31 | + /venv/bin/python -m pip install --upgrade \ |
38 | 32 | pip \ |
39 | 33 | build \ |
40 | 34 | importlib-metadata \ |
41 | | - psycopg2-binary && \ |
42 | | - python -m pip install /python-murfey[server] && \ |
43 | | - chmod -R a+x /venv |
| 35 | + psycopg2-binary \ |
| 36 | + && \ |
| 37 | + /venv/bin/python -m pip install /python-murfey[server] |
| 38 | + |
44 | 39 |
|
45 | | -# Copy installed files across to final image |
| 40 | +# Transfer completed Murfey build to a clean image |
46 | 41 | FROM base |
47 | | -COPY --from=build --chown="${userid}":"${groupid}" /venv/ /venv/ |
| 42 | + |
| 43 | +# Define external build arguments |
| 44 | +ARG groupid |
| 45 | +ARG groupname |
| 46 | +ARG userid |
| 47 | + |
| 48 | +# Copy completed Murfey build across, install Vim, and set user and group permissions |
| 49 | +COPY --from=build /venv/ /venv/ |
| 50 | +RUN groupadd -r -g "${groupid}" "${groupname}" && \ |
| 51 | + useradd -r -M "${groupname}" -u "${userid}" -g "${groupname}" && \ |
| 52 | + chown -R "${userid}":"${groupid}" /venv && \ |
| 53 | + chmod -R a+x /venv |
| 54 | +ENV PATH=/venv/bin:$PATH |
| 55 | +USER "${userid}":"${groupid}" |
0 commit comments