Merge pull request 'Fix: Update container image dependencies' (#7) from experimental into main
All checks were successful
Docker Build and Push (Multi-architecture) / build-and-push (push) Successful in 21s
All checks were successful
Docker Build and Push (Multi-architecture) / build-and-push (push) Successful in 21s
Reviewed-on: #7
This commit is contained in:
18
dockerfile
18
dockerfile
@@ -18,13 +18,13 @@ COPY requirements.txt .
|
|||||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||||
pip install --no-cache-dir -r requirements.txt
|
pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
# Final stage - using smaller base image
|
# Final stage - using slim
|
||||||
FROM python:3.11-alpine3.18
|
FROM python:3.11-slim
|
||||||
|
|
||||||
# Install minimal runtime dependencies
|
# Install minimal runtime dependencies
|
||||||
RUN apk add --no-cache \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
tini \
|
tini \
|
||||||
&& rm -rf /var/cache/apk/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -34,18 +34,22 @@ COPY --from=builder /opt/venv /opt/venv
|
|||||||
ENV PATH="/opt/venv/bin:$PATH"
|
ENV PATH="/opt/venv/bin:$PATH"
|
||||||
|
|
||||||
# Create a non-root user
|
# Create a non-root user
|
||||||
RUN addgroup -S bot && adduser -S bot -G bot
|
RUN groupadd -r bot && useradd -r -g bot bot
|
||||||
|
|
||||||
# Copy necessary files
|
# Copy necessary files
|
||||||
COPY --chown=bot:bot *.py ./
|
COPY --chown=bot:bot *.py ./
|
||||||
COPY --chown=bot:bot entrypoint.sh ./
|
COPY --chown=bot:bot entrypoint.sh ./
|
||||||
# Add other necessary directories/files as needed
|
|
||||||
|
|
||||||
# Create directories for persistent storage
|
# Create directories for persistent storage
|
||||||
RUN mkdir -p logs embed && \
|
RUN mkdir -p logs embed && \
|
||||||
chown -R bot:bot /app logs embed && \
|
chown -R bot:bot /app logs embed && \
|
||||||
chmod -R 777 /app logs embed
|
chmod -R 777 /app logs embed
|
||||||
|
|
||||||
|
# Create and set permissions for matplotlib config directory
|
||||||
|
RUN mkdir -p /tmp/matplotlib && \
|
||||||
|
chown -R bot:bot /tmp/matplotlib && \
|
||||||
|
chmod -R 777 /tmp/matplotlib
|
||||||
|
|
||||||
# Switch to non root user
|
# Switch to non root user
|
||||||
USER bot
|
USER bot
|
||||||
|
|
||||||
@@ -54,6 +58,8 @@ ENV PYTHONUNBUFFERED=1
|
|||||||
ENV CONFIG_PATH=/app/config.ini
|
ENV CONFIG_PATH=/app/config.ini
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
ENV PYTHONPYCACHEPREFIX=/tmp
|
ENV PYTHONPYCACHEPREFIX=/tmp
|
||||||
|
ENV MPLCONFIGDIR=/tmp/matplotlib
|
||||||
|
ENV MPLBACKEND=Agg
|
||||||
|
|
||||||
# Run the bot using tini and entrypoint script
|
# Run the bot using tini and entrypoint script
|
||||||
ENTRYPOINT ["tini", "--", "/bin/sh", "entrypoint.sh"]
|
ENTRYPOINT ["tini", "--", "/bin/sh", "entrypoint.sh"]
|
||||||
Reference in New Issue
Block a user