mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2025-04-19 08:55:12 +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
|
# Build stage: install build dependencies and Python packages
|
||||||
FROM python:3.12
|
FROM python:3.12-slim AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
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 \
|
wireguard \
|
||||||
iptables \
|
iptables \
|
||||||
iproute2 \
|
iproute2 \
|
||||||
@ -11,29 +26,23 @@ RUN apt-get update && apt-get install -y \
|
|||||||
inetutils-ping \
|
inetutils-ping \
|
||||||
inetutils-traceroute \
|
inetutils-traceroute \
|
||||||
nano \
|
nano \
|
||||||
vim-nox \
|
|
||||||
openssl \
|
openssl \
|
||||||
dnsutils \
|
dnsutils \
|
||||||
rrdtool \
|
rrdtool \
|
||||||
librrd-dev \
|
procps \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# those are the really necessary packages
|
# Copy installed Python packages from the builder stage
|
||||||
#RUN apt-get update && apt-get install -y \
|
COPY --from=builder /install /usr/local
|
||||||
# wireguard \
|
|
||||||
# iptables \
|
|
||||||
# openssl \
|
|
||||||
# && rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
COPY requirements.txt /app/
|
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
|
||||||
|
|
||||||
|
# Copy the application code
|
||||||
COPY . /app/
|
COPY . /app/
|
||||||
|
|
||||||
RUN chmod +x /app/init.sh
|
# Set execution permissions on scripts
|
||||||
RUN chmod +x /app/entrypoint.sh
|
RUN chmod +x /app/init.sh && chmod +x /app/entrypoint.sh
|
||||||
|
|
||||||
ARG SERVER_ADDRESS
|
ARG SERVER_ADDRESS
|
||||||
ARG DEBUG_MODE
|
ARG DEBUG_MODE
|
||||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
|
||||||
|
|
||||||
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
CMD ["/app/init.sh"]
|
CMD ["/app/init.sh"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user