From 537b73b79153cfb79ace4c28f42697a50aec4439 Mon Sep 17 00:00:00 2001 From: Ali Maktabi Date: Mon, 16 Sep 2024 18:27:56 +0330 Subject: [PATCH] separate development and production build images --- Dockerfile | 20 ++++---------------- Dockerfile.prod | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 16 deletions(-) create mode 100644 Dockerfile.prod diff --git a/Dockerfile b/Dockerfile index 858f6e7..fe50d7d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,5 @@ -FROM pypy:3.10 - - -RUN apt-get update && apt-get install -y \ - curl \ - build-essential \ - libssl-dev \ - pkg-config \ - && rm -rf /var/lib/apt/lists/* - -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y -ENV PATH="/root/.cargo/bin:${PATH}" -RUN rustc --version && cargo --version - +# Use an official Python runtime as a parent image +FROM python:3.10.11 # Set environment variables ENV PYTHONDONTWRITEBYTECODE 1 @@ -23,6 +11,7 @@ WORKDIR /usr/src/app RUN apt update && apt install gcc + # RUN apt-get update && \ # apt-get install -y --no-install-recommends \ # build-essential \ @@ -38,7 +27,6 @@ RUN pip install --upgrade pip COPY ./requirements.txt . RUN pip install -r requirements.txt -RUN ln -s /usr/local/bin/pypy3 /usr/local/bin/python # Copy project @@ -47,4 +35,4 @@ COPY ./start.sh . COPY ./celery.sh . -# RUN pypy3 manage.py collectstatic --noinput +RUN python manage.py collectstatic --noinput diff --git a/Dockerfile.prod b/Dockerfile.prod new file mode 100644 index 0000000..858f6e7 --- /dev/null +++ b/Dockerfile.prod @@ -0,0 +1,50 @@ +FROM pypy:3.10 + + +RUN apt-get update && apt-get install -y \ + curl \ + build-essential \ + libssl-dev \ + pkg-config \ + && rm -rf /var/lib/apt/lists/* + +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y +ENV PATH="/root/.cargo/bin:${PATH}" +RUN rustc --version && cargo --version + + +# Set environment variables +ENV PYTHONDONTWRITEBYTECODE 1 +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/* + + +RUN pip install --upgrade pip +COPY ./requirements.txt . +RUN pip install -r requirements.txt + +RUN ln -s /usr/local/bin/pypy3 /usr/local/bin/python + + +# Copy project +COPY ./src . +COPY ./start.sh . +COPY ./celery.sh . + + +# RUN pypy3 manage.py collectstatic --noinput