feat: created docker-compose.yml
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
.github/
|
.github/
|
||||||
.pytest_cache/
|
.pytest_cache/
|
||||||
|
data/
|
||||||
coverage.xml
|
coverage.xml
|
||||||
|
docker-compose.dev.yml
|
||||||
|
docker-compose.yml
|
||||||
|
|||||||
@@ -39,6 +39,34 @@ celery -A config worker -B -l debug
|
|||||||
pytest --cov
|
pytest --cov
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Docker
|
||||||
|
|
||||||
|
### Descarga
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker pull ghcr.io/pablo-moreno/shoppy
|
||||||
|
```
|
||||||
|
|
||||||
|
### Construir imagen
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build -t shoppy .
|
||||||
|
```
|
||||||
|
|
||||||
|
### Crear contenedor
|
||||||
|
|
||||||
|
**API**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -it --rm -p 8000:80 -e RUN_SERVER=TRUE --env-file=.env shoppy_api
|
||||||
|
```
|
||||||
|
|
||||||
|
**Tareas en segundo plano**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -it --rm -p 8000:80 -e RUN_CELERY=TRUE --env-file=.env shoppy_tasks
|
||||||
|
```
|
||||||
|
|
||||||
## Variables de entorno
|
## Variables de entorno
|
||||||
|
|
||||||
Puedes crear un archivo `.env` con las siguientes variables de entorno.
|
Puedes crear un archivo `.env` con las siguientes variables de entorno.
|
||||||
@@ -66,25 +94,3 @@ Puedes crear un archivo `.env` con las siguientes variables de entorno.
|
|||||||
| REDSYS_TERMINAL | 001 | Terminal de Redsys |
|
| REDSYS_TERMINAL | 001 | Terminal de Redsys |
|
||||||
| REDSYS_CURRENCY_CODE | 978 | Código de moneda de Redsys |
|
| REDSYS_CURRENCY_CODE | 978 | Código de moneda de Redsys |
|
||||||
| REDSYS_TPV_DOMAIN | | Dominio del TPV para redirección de Redsys |
|
| REDSYS_TPV_DOMAIN | | Dominio del TPV para redirección de Redsys |
|
||||||
|
|
||||||
## Docker
|
|
||||||
|
|
||||||
### Construir imagen
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker build -t shoppy .
|
|
||||||
```
|
|
||||||
|
|
||||||
### Crear contenedor
|
|
||||||
|
|
||||||
**API**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run -it --rm -p 8000:80 -e RUN_SERVER=TRUE --env-file=.env shoppy_api
|
|
||||||
```
|
|
||||||
|
|
||||||
**Tareas en segundo plano**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run -it --rm -p 8000:80 -e RUN_CELERY=TRUE --env-file=.env shoppy_tasks
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:14.1
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: admin
|
||||||
|
POSTGRES_PASSWORD: development
|
||||||
|
POSTGRES_DB: default
|
||||||
|
volumes:
|
||||||
|
- "./data/postgres:/var/lib/postgres/data"
|
||||||
|
|
||||||
|
minio:
|
||||||
|
image: bitnami/minio:latest
|
||||||
|
ports:
|
||||||
|
- "9190:9000"
|
||||||
|
- "9191:9001"
|
||||||
|
volumes:
|
||||||
|
- "./data/minio/:/bitnami/minio/data"
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis
|
||||||
|
|
||||||
|
shoppy:
|
||||||
|
image: shoppy
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
environment:
|
||||||
|
DEBUG: "True"
|
||||||
|
DATABASE_URL: "postgres://admin:development@postgres:5432/default"
|
||||||
|
S3_HOST: "http://172.17.0.1:9190"
|
||||||
|
S3_LOCATION: "backend"
|
||||||
|
S3_STORAGE_BUCKET_NAME: "shoppy"
|
||||||
|
S3_ENDPOINT_URL: "http://172.17.0.1:9190"
|
||||||
|
S3_ENABLED: "True"
|
||||||
|
S3_ACCESS_KEY_ID: "shoppy-access-key"
|
||||||
|
S3_SECRET_ACCESS_KEY: "shoppy-secret-key"
|
||||||
|
RUN_SERVER: "TRUE"
|
||||||
|
CELERY_BROKER_URL: "redis://redis:6379/0"
|
||||||
|
links:
|
||||||
|
- postgres
|
||||||
|
- minio
|
||||||
|
- redis
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
|
- minio
|
||||||
|
- redis
|
||||||
|
|
||||||
|
shoppy_tasks:
|
||||||
|
image: shoppy
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: "postgres://admin:development@postgres:5432/default"
|
||||||
|
S3_HOST: "http://172.17.0.1:9190"
|
||||||
|
S3_LOCATION: "backend"
|
||||||
|
S3_STORAGE_BUCKET_NAME: "shoppy"
|
||||||
|
S3_ENDPOINT_URL: "http://172.17.0.1:9190"
|
||||||
|
S3_ENABLED: "True"
|
||||||
|
S3_ACCESS_KEY_ID: "shoppy-access-key"
|
||||||
|
S3_SECRET_ACCESS_KEY: "shoppy-secret-key"
|
||||||
|
RUN_CELERY: "TRUE"
|
||||||
|
CELERY_BROKER_URL: "redis://redis:6379/0"
|
||||||
|
links:
|
||||||
|
- postgres
|
||||||
|
- minio
|
||||||
|
- redis
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
|
- minio
|
||||||
|
- redis
|
||||||
@@ -1,3 +1,12 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from files.models import FileUpload
|
||||||
|
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
@admin.register(FileUpload)
|
||||||
|
class FileUploadAdmin(admin.ModelAdmin):
|
||||||
|
list_display = (
|
||||||
|
'id',
|
||||||
|
'file',
|
||||||
|
)
|
||||||
|
|||||||
+12
-11
@@ -1,4 +1,7 @@
|
|||||||
server {
|
server {
|
||||||
|
access_log /var/log/nginx/access.log;
|
||||||
|
error_log /var/log/nginx/error.log notice;
|
||||||
|
|
||||||
listen 80;
|
listen 80;
|
||||||
|
|
||||||
# Static files
|
# Static files
|
||||||
@@ -9,6 +12,15 @@ server {
|
|||||||
# Reverse proxy
|
# Reverse proxy
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://127.0.0.1:8000;
|
proxy_pass http://127.0.0.1:8000;
|
||||||
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
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;
|
||||||
|
proxy_set_header X-Forwarded-Host $host;
|
||||||
|
proxy_set_header X-Forwarded-Port $server_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
# security headers
|
# security headers
|
||||||
@@ -24,15 +36,4 @@ server {
|
|||||||
gzip_proxied any;
|
gzip_proxied any;
|
||||||
gzip_comp_level 6;
|
gzip_comp_level 6;
|
||||||
gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml;
|
gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml;
|
||||||
|
|
||||||
# Proxy
|
|
||||||
proxy_cache_bypass $http_upgrade;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection "upgrade";
|
|
||||||
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;
|
|
||||||
proxy_set_header X-Forwarded-Host $host;
|
|
||||||
proxy_set_header X-Forwarded-Port $server_port;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
boto3==1.34.105
|
||||||
celery==5.4.0
|
celery==5.4.0
|
||||||
django==5.0.6
|
django==5.0.6
|
||||||
django-cors-headers==3.13.0
|
django-cors-headers==3.13.0
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ RUN_CELERY=${RUN_CELERY:="FALSE"}
|
|||||||
|
|
||||||
|
|
||||||
if [ $RUN_SERVER = "TRUE" ]; then
|
if [ $RUN_SERVER = "TRUE" ]; then
|
||||||
|
chown -R www-data:www-data static/
|
||||||
|
python manage.py collectstatic --no-input
|
||||||
service nginx start
|
service nginx start
|
||||||
uvicorn --workers $ASGI_WORKERS --host $ASGI_HOST --port $ASGI_PORT config.asgi:application
|
uvicorn --workers $ASGI_WORKERS --host $ASGI_HOST --port $ASGI_PORT config.asgi:application
|
||||||
elif [ $RUN_CELERY = "TRUE" ]; then
|
elif [ $RUN_CELERY = "TRUE" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user