From 0f86a8ae69bcb633508c48ccf044d23abdd25d9e Mon Sep 17 00:00:00 2001 From: Amir Date: Tue, 27 Aug 2024 20:58:41 +0200 Subject: [PATCH] Second try --- Dockerfile | 44 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/Dockerfile b/Dockerfile index 499ede9a..a39851be 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,47 +1,33 @@ FROM python:3.8.1-slim-buster -RUN useradd wagtail +ENV PYTHONUNBUFFERED=1 -# Set working directory -WORKDIR /app - -# Set environment variables -ENV PYTHONUNBUFFERED=1 \ - PORT=8000 - -# Install system packages required by Wagtail and Django -RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \ +# Install system dependencies +RUN apt-get update --yes && apt-get install --yes --no-install-recommends \ build-essential \ libpq-dev \ - libmariadbclient-dev \ libjpeg62-turbo-dev \ zlib1g-dev \ libwebp-dev \ + gettext \ && rm -rf /var/lib/apt/lists/* -# Upgrade pip to the latest version -RUN pip install --upgrade pip +# Add and set up the working directory +WORKDIR /app -# Install the application server -RUN pip install "gunicorn==20.0.4" +# Copy requirements file and install dependencies +COPY requirements.txt /app/ +RUN pip install --upgrade pip \ + && pip install -r /app/requirements.txt -COPY requirements.txt /app/requirements.txt -RUN pip install -r /app/requirements.txt - -# Copy the source code of the project into the container -COPY --chown=wagtail:wagtail . . - -# Set this directory to be owned by the "wagtail" user -RUN chown wagtail:wagtail /app - -# Use user "wagtail" to run the build commands below and the server itself -USER wagtail +# Copy application code +COPY . /app/ # Collect static files RUN python manage.py collectstatic --noinput --clear -# Port used by this container to serve HTTP +# Expose the port the app runs on EXPOSE 8000 -# Runtime command that executes when "docker run" is called -CMD ["sh", "-c", "python manage.py migrate --noinput && gunicorn saburly.wsgi:application"] +# Run the application server +CMD ["gunicorn", "--bind", "0.0.0.0:8000", "saburly.wsgi:application"] \ No newline at end of file