-
Notifications
You must be signed in to change notification settings - Fork 15
/
Dockerfile
85 lines (61 loc) · 1.66 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# -- Base image --
FROM python:3.12.0-slim AS base
# Upgrade pip to its latest release to speed up dependencies installation
RUN pip install --upgrade pip
# Upgrade system packages to install security updates
RUN apt-get update && \
apt-get -y upgrade && \
rm -rf /var/lib/apt/lists/*
# -- Builder --
FROM base AS builder
WORKDIR /build
COPY . /build/
RUN apt-get update && \
apt-get install -y \
build-essential \
gcc \
libc6-dev \
libffi-dev && \
rm -rf /var/lib/apt/lists/*
RUN pip install .[full]
# -- Core --
FROM base AS core
RUN apt-get update && \
apt-get install -y \
curl \
jq \
wget && \
rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local /usr/local
WORKDIR /app
# -- Development --
FROM core AS development
# Copy all sources, not only runtime-required files
COPY . /app/
# Only the M1 Mac images need these packages installed
ARG TARGETPLATFORM
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; \
then apt-get update && \
apt-get install -y \
build-essential \
gcc && \
rm -rf /var/lib/apt/lists/*; \
fi;
# Install git for documentation deployment
RUN apt-get update && \
apt-get install -y \
git && \
rm -rf /var/lib/apt/lists/*;
# Uninstall ralph and re-install it in editable mode along with development
# dependencies
RUN pip uninstall -y ralph-malph
RUN pip install -e .[dev]
# Un-privileged user running the application
ARG DOCKER_USER=1000
USER ${DOCKER_USER}
# -- Production --
FROM core AS production
# Un-privileged user running the application
ARG DOCKER_USER=1000
USER ${DOCKER_USER}
CMD ["ralph"]