Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Commit

Permalink
optimized build on docker
Browse files Browse the repository at this point in the history
  • Loading branch information
alimaktabi committed Sep 16, 2024
1 parent e80e6d5 commit c5f94ac
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
FROM pypy:3.10

# Builder stage
FROM pypy:3.10 AS builder

# Install dependencies for Rust and Python build requirements
RUN apt-get update && apt-get install -y \
curl \
build-essential \
libssl-dev \
pkg-config \
gcc \
&& rm -rf /var/lib/apt/lists/*

# Install Rust and Cargo
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustc --version && cargo --version

# Set work directory
WORKDIR /usr/src/app

# Upgrade pip and install Python dependencies into a virtual environment
RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt

# Final stage (runtime)
FROM pypy:3.10

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
Expand All @@ -20,31 +33,18 @@ ENV PYTHONUNBUFFERED 1
# Set work directory
WORKDIR /usr/src/app

RUN apt update && apt install gcc


# RUN apt-get update && \
# apt-get install -y --no-install-recommends \
# build-essential \
# gcc \
# libpq-dev \
# libc-dev \
# netcat-traditional \
# && apt-get clean && \
# rm -rf /var/lib/apt/lists/*
# Install GCC
RUN apt update && apt install -y gcc

# Copy installed Python packages from builder stage
COPY --from=builder /opt/pypy/lib/pypy3.10/site-packages /opt/pypy/lib/pypy3.10/site-packages

RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt

# Link pypy3 to python
RUN ln -s /usr/local/bin/pypy3 /usr/local/bin/python


# Copy project
# Copy project files
COPY ./src .
COPY ./start.sh .
COPY ./celery.sh .


# RUN pypy3 manage.py collectstatic --noinput

0 comments on commit c5f94ac

Please sign in to comment.