-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (52 loc) · 1.43 KB
/
Dockerfile
File metadata and controls
55 lines (52 loc) · 1.43 KB
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
# ===========================
# Stage 1: Builder (Alpine)
# ===========================
FROM python:3.9.25-alpine3.21 AS builder
WORKDIR /opt/server
# Build deps for uwsgi & friends
RUN apk add --no-cache \
build-base \
linux-headers \
pcre-dev
# Only requirements first for caching
COPY requirements.txt .
# Install into /install (just like you did)
RUN pip3 install --prefix=/install -r requirements.txt
# ==========================
# Stage 2: Runtime (Alpine)
# ==========================
FROM python:3.9.25-alpine3.21
EXPOSE 8080
WORKDIR /opt/server
# Runtime deps only
RUN apk add --no-cache pcre
# Create non-root user
RUN addgroup -S roboshop && adduser -S roboshop -G roboshop
# Copy installed packages from builder
COPY --from=builder /install /usr/local
# Copy app files
COPY --chown=roboshop:roboshop payment.ini *.py requirements.txt .
ENV CART_HOST="cart" \
CART_PORT="8080" \
USER_HOST="user" \
USER_PORT="8080" \
AMQP_HOST="rabbitmq" \
AMQP_USER="roboshop" \
AMQP_PASS="roboshop123"
USER roboshop
CMD ["uwsgi", "--ini", "payment.ini"]
# FROM python:3.9
# EXPOSE 8080
# WORKDIR /opt/server
# COPY payment.ini .
# COPY *.py .
# COPY requirements.txt .
# RUN pip3 install -r requirements.txt
# ENV CART_HOST="cart" \
# CART_PORT="8080" \
# USER_HOST="user" \
# USER_PORT="8080" \
# AMQP_HOST="rabbitmq" \
# AMQP_USER="roboshop" \
# AMQP_PASS="roboshop123"
# CMD ["uwsgi","--ini","payment.ini"]