Skip to content

Commit 6c9b4de

Browse files
committed
Fixed issue with user permissions not transferring correctly between images
1 parent d0dacc3 commit 6c9b4de

File tree

1 file changed

+35
-27
lines changed

1 file changed

+35
-27
lines changed

Dockerfiles/murfey-server

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,55 @@
11
# Template build command
22
# 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
33

4-
# Set up the Python base image to build with
4+
# Set up the base image to build with
55
FROM docker.io/library/python:3.12.8-slim-bullseye AS base
66

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/*
1115

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/
1620
RUN apt-get update && \
1721
apt-get upgrade -y && \
1822
apt-get install -y --no-install-recommends \
1923
build-essential \
2024
busybox \
2125
git \
26+
libpq-dev \
2227
net-tools \
23-
libpq-dev && \
28+
&& \
2429
busybox --install && \
25-
rm -rf /var/lib/apt/lists/* && \
26-
groupadd -r -g "${groupid}" "${groupname}" && \
27-
useradd -r -M "${groupname}" -u "${userid}" -g "${groupname}" && \
2830
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 \
3832
pip \
3933
build \
4034
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+
4439

45-
# Copy installed files across to final image
40+
# Transfer completed Murfey build to a clean image
4641
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

Comments
 (0)