mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-04-19 23:46:53 +00:00
builds
This commit is contained in:
parent
eb600b7a0c
commit
871d604ef4
38
.build/prod/api.Dockerfile
Normal file
38
.build/prod/api.Dockerfile
Normal file
@ -0,0 +1,38 @@
|
||||
FROM python:3.11.4-slim-buster AS builder
|
||||
|
||||
WORKDIR /var/www/html/
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends gcc
|
||||
|
||||
RUN pip install --upgrade pip
|
||||
COPY . /var/www/html/
|
||||
COPY ./requirements.txt .
|
||||
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /var/www/html/wheels -r requirements.txt
|
||||
|
||||
FROM python:3.11.4-slim-buster
|
||||
|
||||
WORKDIR /var/www/html/
|
||||
|
||||
RUN mkdir /var/www/html/staticfiles -p && chmod -R 777 /var/www/html/staticfiles
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends netcat
|
||||
COPY --from=builder /var/www/html/wheels /wheels
|
||||
COPY --from=builder /var/www/html/requirements.txt .
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install --no-cache /wheels/*
|
||||
|
||||
COPY . /var/www/html/
|
||||
# copy entrypoint.prod.sh
|
||||
COPY .build/prod/entrypoint.sh /entrypoint.sh
|
||||
|
||||
#RUN python manage.py collectstatic
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
VOLUME /var/www/html/staticfiles
|
||||
|
||||
|
||||
CMD gunicorn apibase.wsgi:application --bind 0.0.0.0:5000 --workers=2
|
13
.build/prod/compose.yml
Normal file
13
.build/prod/compose.yml
Normal file
@ -0,0 +1,13 @@
|
||||
services:
|
||||
api:
|
||||
build:
|
||||
context: ../../
|
||||
dockerfile: .build/prod/api.Dockerfile
|
||||
hostname: sarlink-portal-api
|
||||
image: git.shihaam.dev/sarlink/sarlink-portal-api/api
|
||||
nginx:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./nginx.Dockerfile
|
||||
hostname: sarlink-portal-api-nginx
|
||||
image: git.shihaam.dev/sarlink/sarlink-portal-api/nginx
|
14
.build/prod/entrypoint.sh
Executable file
14
.build/prod/entrypoint.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "$DATABASE" = "postgres" ]
|
||||
then
|
||||
echo "Waiting for postgres..."
|
||||
|
||||
while ! nc -z $POSTGRES_HOST $POSTGRES_PORT; do
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
echo "PostgreSQL started"
|
||||
fi
|
||||
|
||||
exec "$@"
|
11
.build/prod/nginx.Dockerfile
Normal file
11
.build/prod/nginx.Dockerfile
Normal file
@ -0,0 +1,11 @@
|
||||
FROM nginx
|
||||
|
||||
# Install basic tools
|
||||
RUN apt update \
|
||||
&& apt install curl nano iputils-ping zip unzip -y --no-install-recommends \
|
||||
&& apt auto-remove -y \
|
||||
&& apt clean -y
|
||||
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
WORKDIR /etc/nginx
|
22
.build/prod/nginx.conf
Normal file
22
.build/prod/nginx.conf
Normal file
@ -0,0 +1,22 @@
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
server_name _;
|
||||
access_log /dev/stdout;
|
||||
error_log /dev/stdout info;
|
||||
|
||||
# Serve static files
|
||||
location /static/ {
|
||||
alias /var/www/html/staticfiles/;
|
||||
}
|
||||
|
||||
# Forward requests to Gunicorn
|
||||
location / {
|
||||
proxy_pass http://api:5000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
client_max_body_size 6M;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user