-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
48 lines (38 loc) · 1.26 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
ARG PYTHON_VERSION=3.12.2
# Stage 1: Build
FROM python:${PYTHON_VERSION} AS builder
WORKDIR /app
# Copy only the necessary files for installing dependencies
COPY pyproject.toml poetry.lock ./
# Install Poetry and dependencies
RUN pip install poetry poetry-plugin-export
RUN poetry export --extras=binary -o requirements.txt
# Stage 2: Final
FROM python:${PYTHON_VERSION} AS production
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
# Copy the requirements.txt file from the builder stage to the current directory
COPY --from=builder /app/requirements.txt .
# Set the UID argument to a default value of 10001
ARG UID=10001
# Create a new user with the specified UID and set its properties
# Install the Python packages listed in the requirements.txt file
RUN --mount=type=cache,target=/root/.cache/pip \
adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser \
&& chown -R appuser /app \
&& python -m pip install -r requirements.txt
# Copy the rest of the project files
COPY . .
# Set the user to run the container as
USER appuser
# Set the entry point for your application
ENTRYPOINT ["python", "-m", "dump_psql_roles_grants"]
CMD ["export"]