Dockerfile

###########
# BUILDER #
###########

# pull official base image
FROM python:3.11.2-slim as builder

# set work directory
WORKDIR /app

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# install system dependencies
RUN apt-get update && \
 apt-get install -y postgresql-server-dev-all gcc python3-dev musl-dev

# lint
RUN pip install --upgrade pip
RUN pip install flake8==6.0.0
COPY . .
RUN flake8 --ignore=E501,F401,E231,F405,F403,W292,E712,W503 ./app

# install python dependencies
COPY ./app/requirements ./requirements
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r 
./requirements/prod.txt


#########
# FINAL #
#########
# pull official base image
FROM python:3.11.2-slim

# create directory for the app user
RUN mkdir -p /home/app

# create the app user
RUN addgroup --system app && adduser --system --group app

# Set working directory
WORKDIR /app

# install dependencies
COPY --from=builder /usr/src/app/wheels /wheels
COPY --from=builder /app/requirements/prod.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache /wheels/*


# Install dependencies
COPY ./app/requirements ./requirements
RUN pip install --upgrade pip
RUN pip install -r ./requirements/prod.txt

# Copy entrypoint.sh
COPY ./docker/prod/entrypoint.sh /entrypoint.sh
RUN sed -i 's/\r$//g'  /entrypoint.sh
RUN chmod +x /entrypoint.sh

COPY ./app /app


# chown all the files to the app user
RUN chown -R app:app /app


# change to the app user
USER app
ENTRYPOINT [ "/entrypoint.sh" ]

On Thursday, July 27, 2023 at 5:37:57 AM UTC+1 [email protected] wrote:

> Hello,
> kindly help me with a solution i have a issue with my nginx it uses 
> docker-compose with clery and flower dashboard which point to difrent url 
> the flower url works fine as expected but the main django sever not working 
> saying page not found
>
> docker-compose
> version: '3.9'
>
> services:
>   api: &api
>     build:
>       context: .
>       dockerfile: docker/prod/Dockerfile
>     image: 1.dkr.ecr.eu-west-2.amazonaws.com/pro:web
>     command: gunicorn core.wsgi:application --bind 0.0.0.0:8000 --timeout 
> 420
>     logging:
>       driver: "awslogs"
>       options:
>         awslogs-region: "region"
>         awslogs-group: "amazon-linux-proxi"
>         awslogs-stream: "amazon-linux-proxi"
>     volumes:
>       - ./app:/app
>     ports:
>       - '8000:8000'
>     env_file:
>       - ./.env
>     restart: unless-stopped
>       
>
>   celery:
>     <<: *api
>     command: celery -A core worker -l info
>     ports: []
>     volumes:
>       - ./app:/app
>     env_file:
>       - ./.env
>     depends_on:
>       - api
>       
>
>   celery-beat:
>     <<: *api
>     user: root
>     command: celery -A core beat -l info 
>     ports: []
>     volumes:
>       - ./app:/app
>     env_file:
>       - ./.env
>     depends_on:
>       - api
>       - celery
>       
>
>   dashboard:
>     <<: *api
>     command: celery --broker=${RABBITMQ_URL} flower --port=5555
>     ports:
>       - '25559:5555'
>     env_file:
>       - ./.env
>     depends_on:
>       - api
>       
>       - celery
>       - celery-beat 
>
>
> server {
>     server_name tools.com
>     client_max_body_size 100M;
>
>     location / {
>         proxy_pass http://127.0.0.1:8000;
>         proxy_set_header Host $host;
>         proxy_set_header X-Real-IP $remote_addr;
>         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>     }
>
>
>
>     listen 443 ssl; # managed by Certbot
>     ssl_certificate /etc/letsencrypt/live/tools.com/fullchain.pem; # 
> managed by Certbot
>     ssl_certificate_key /etc/letsencrypt/live/tools.com/privkey.pem; # 
> managed by Certbot
>     include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
>     ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
>
> }
> server {
>     if ($host = tools.com) {
>         return 301 https://$host$request_uri;
>     } # managed by Certbot
>
>
>     server_name tools.com
>     client_max_body_size 100M;
>     listen 80;
>     return 404; # managed by Certbot
>
>
> }
>
>
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d0fd6508-f5f1-41af-aae0-efdb695f2aden%40googlegroups.com.

Reply via email to