-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
31 lines (23 loc) · 894 Bytes
/
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
# Stage 1: Build and compile environment
FROM python:3.12.2-alpine AS compile-image
# Setup a virtual environment to isolate our package dependencies locally
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Stage 2: Final image build
FROM python:3.12.2-alpine
# Copy virtual environment from the build stage
COPY --from=compile-image /opt/venv /opt/venv
# Setup environment variable to ensure scripts run in virtual environment
ENV PATH="/opt/venv/bin:$PATH"
# Add a non-root user for running the application
RUN adduser -D appuser
USER appuser
WORKDIR /app
# Copy application files
COPY --chown=appuser:appuser krakenohlc/ krakenohlc/
COPY --chown=appuser:appuser __main__.py .
# Run the application
CMD ["python", "-u", "__main__.py"]