Skip to content

Commit

Permalink
split image build in to phases to install git on builder
Browse files Browse the repository at this point in the history
  • Loading branch information
inean committed Sep 2, 2024
1 parent 5a3f996 commit e3adb80
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
# Define the build argument with no default value
ARG PYTHON_VERSION
ARG PYTHON_VERSION=3.10

# Use the official Python image as the base image
# Builder stage
FROM python:${PYTHON_VERSION}-slim AS builder

# hadolint ignore=DL3008
RUN <<EOF
apt-get update
apt-get install --no-install-recommends -y git
EOF

# Set the working directory:
WORKDIR /app

# Copy and install dependencies:
COPY requirements.lock ./
RUN PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir -r requirements.lock

# Copy the application source code:
COPY src .

# Final stage
FROM python:${PYTHON_VERSION}-slim

# Define the build argument with a default value
Expand All @@ -16,12 +35,8 @@ LABEL maintainer="Carlos Martín (github.com/inean)"
# Set the working directory:
WORKDIR /app

# Copy and install dependencies:
COPY requirements.lock ./
RUN PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir -r requirements.lock

# Copy the application source code:
COPY src .
# Copy dependencies and source code from the builder stage
COPY --from=builder /app /app

# Run the application:
ENTRYPOINT ["python", "-m", "dns_synchub"]
Expand Down

0 comments on commit e3adb80

Please sign in to comment.