categorias-productos #51 #52
20
django.registry.Dockerfile
Normal file
20
django.registry.Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
||||
# Imagen de produccion del backend para publicar en el registry de Gitea.
|
||||
# Autocontenida: incluye el codigo y un entrypoint que aplica migraciones,
|
||||
# colecta estaticos y arranca gunicorn. Coolify solo hace pull y define env vars.
|
||||
FROM python:3.12-slim
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1
|
||||
|
||||
WORKDIR /app/
|
||||
|
||||
COPY requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY tienda_ilusion/ /app/
|
||||
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
23
docker/entrypoint.sh
Executable file
23
docker/entrypoint.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
# Entrypoint de la imagen de produccion del backend.
|
||||
#
|
||||
# Sin argumentos: aplica migraciones, colecta estaticos y arranca gunicorn.
|
||||
# Con argumentos: ejecuta ese comando tal cual (util para operaciones, p. ej.
|
||||
# docker run --rm <imagen> python manage.py createsuperuser).
|
||||
set -e
|
||||
|
||||
if [ "$#" -gt 0 ]; then
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
echo "[entrypoint] Aplicando migraciones..."
|
||||
python manage.py migrate --noinput
|
||||
|
||||
echo "[entrypoint] Colectando estaticos..."
|
||||
python manage.py collectstatic --noinput
|
||||
|
||||
echo "[entrypoint] Arrancando gunicorn en 0.0.0.0:8000..."
|
||||
exec gunicorn config.wsgi:application \
|
||||
--bind 0.0.0.0:8000 \
|
||||
--workers "${GUNICORN_WORKERS:-4}" \
|
||||
--timeout 120
|
||||
37
scripts/build-push-image.sh
Executable file
37
scripts/build-push-image.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
# Construye y publica la imagen del backend en el container registry de Gitea.
|
||||
#
|
||||
# Uso:
|
||||
# scripts/build-push-image.sh
|
||||
#
|
||||
# Requiere haber hecho login previo en el registry (hazlo tu, con tu token):
|
||||
# docker login gitea.onecluster.org -u <usuario-gitea>
|
||||
# (password = tu token con scope write:package)
|
||||
#
|
||||
# Variables opcionales:
|
||||
# REGISTRY (default: gitea.onecluster.org)
|
||||
# OWNER (default: oneteam)
|
||||
# IMAGE (default: don_confiao_backend)
|
||||
# TAG (default: git short sha)
|
||||
set -euo pipefail
|
||||
|
||||
REGISTRY="${REGISTRY:-gitea.onecluster.org}"
|
||||
OWNER="${OWNER:-oneteam}"
|
||||
IMAGE="${IMAGE:-don_confiao_backend}"
|
||||
DOCKERFILE="${DOCKERFILE:-django.registry.Dockerfile}"
|
||||
|
||||
TAG="${TAG:-$(git rev-parse --short HEAD)}"
|
||||
FULL="${REGISTRY}/${OWNER}/${IMAGE}"
|
||||
|
||||
echo "==> Imagen: ${FULL}:latest y ${FULL}:${TAG}"
|
||||
echo "==> Dockerfile: ${DOCKERFILE}"
|
||||
|
||||
docker build -f "${DOCKERFILE}" \
|
||||
-t "${FULL}:latest" \
|
||||
-t "${FULL}:${TAG}" \
|
||||
.
|
||||
|
||||
docker push "${FULL}:latest"
|
||||
docker push "${FULL}:${TAG}"
|
||||
|
||||
echo "==> Publicado: ${FULL}:latest , ${FULL}:${TAG}"
|
||||
Reference in New Issue
Block a user