mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2025-04-19 00:45:16 +00:00
Refactor Dockerfile to use slim image and multi-stage build
This commit is contained in:
parent
bf34bada92
commit
cacd81c773
45
Dockerfile
45
Dockerfile
@ -1,9 +1,24 @@
|
||||
# Usar uma imagem base do Python
|
||||
FROM python:3.12
|
||||
|
||||
# Build stage: install build dependencies and Python packages
|
||||
FROM python:3.12-slim AS builder
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
# Install build dependencies required for compiling C extensions
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gcc \
|
||||
build-essential \
|
||||
librrd-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy requirements and install Python packages to a separate directory
|
||||
COPY requirements.txt /app/
|
||||
RUN pip install --prefix=/install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Final stage: runtime image
|
||||
FROM python:3.12-slim
|
||||
WORKDIR /app
|
||||
|
||||
# Install necessary runtime packages
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
wireguard \
|
||||
iptables \
|
||||
iproute2 \
|
||||
@ -11,29 +26,23 @@ RUN apt-get update && apt-get install -y \
|
||||
inetutils-ping \
|
||||
inetutils-traceroute \
|
||||
nano \
|
||||
vim-nox \
|
||||
openssl \
|
||||
dnsutils \
|
||||
rrdtool \
|
||||
librrd-dev \
|
||||
procps \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# those are the really necessary packages
|
||||
#RUN apt-get update && apt-get install -y \
|
||||
# wireguard \
|
||||
# iptables \
|
||||
# openssl \
|
||||
# && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY requirements.txt /app/
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
# Copy installed Python packages from the builder stage
|
||||
COPY --from=builder /install /usr/local
|
||||
|
||||
# Copy the application code
|
||||
COPY . /app/
|
||||
|
||||
RUN chmod +x /app/init.sh
|
||||
RUN chmod +x /app/entrypoint.sh
|
||||
# Set execution permissions on scripts
|
||||
RUN chmod +x /app/init.sh && chmod +x /app/entrypoint.sh
|
||||
|
||||
ARG SERVER_ADDRESS
|
||||
ARG DEBUG_MODE
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
CMD ["/app/init.sh"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user