Celestino Rey пре 9 месеци
родитељ
комит
122860c57e
5 измењених фајлова са 9 додато и 67 уклоњено
  1. 4 21
      Dockerfile.alpine
  2. 1 1
      K8S/Makefile
  3. 1 1
      Makefile
  4. 0 39
      src/config/entrypoint-alpine.sh
  5. 3 5
      src/config/entrypoint.sh

+ 4 - 21
Dockerfile.alpine

@@ -1,25 +1,20 @@
 # yup, python 3.11!
-FROM python:3.11-alpine as builder
+FROM python:3.11-alpine 
 
 # install nginx y otras cosas
 RUN apk add nginx netcat-openbsd curl vim jq rsync pango pango-dev cairo postgresql-client bash glib fontconfig font-noto
 
-COPY ./nginx/default.conf /etc/nginx/nginx.conf
 COPY ./src/requirements.txt requirements.txt
 RUN pip install --user --no-cache-dir -r requirements.txt
 
+COPY ./nginx/default.conf /etc/nginx/http.d/nginx.conf
+
 # link nginx logs to container stdout
 RUN ln -sf /dev/stdout /var/log/nginx/access.log && \
     ln -sf /dev/stderr /var/log/nginx/error.log && \
     chgrp -R 0 /var/lib/nginx && \
     chmod -R g=u /var/lib/nginx
 
-FROM python:3.11-alpine as main
-
-RUN apk add nginx netcat-openbsd curl vim jq rsync pango pango-dev cairo postgresql-client bash glib fontconfig font-noto
-
-COPY --from=builder /root/.local /root/.local
-
 ENV PATH="/root/.local/bin:$PATH"
 
 # copy the django code
@@ -31,17 +26,5 @@ RUN chgrp -R 0 ./app && \
 # change our working directory to the django projcet roo
 WORKDIR /app
 
-# create virtual env (notice the location?)
-# update pip
-# install requirements
-#RUN python -m venv /opt/venv && \
-    #/opt/venv/bin/python -m pip install pip --upgrade && \
-    #/opt/venv/bin/python -m pip install -r requirements.txt && \
-    #echo "export PATH=/opt/venv/bin/:$PATH" >> /root/.bashrc && \
-    #chmod +x config/entrypoint.sh
-
-#EXPOSE 8080
-
 # execute our entrypoint.sh file
-CMD ["/app/config/entrypoint-alpine.sh"]
-# CMD ["gunicorn", "misfinanzas.wsgi:application", "--bind", "0.0.0.0:8000", "--access-logfile", "-",  "--error-logfile",  "-", "--log-level", "info"]
+CMD ["/app/config/entrypoint.sh"]

+ 1 - 1
K8S/Makefile

@@ -1,5 +1,5 @@
 export REGISTRY=registry.reymota.es
-export IMG_VERSION = alpine-9
+export IMG_VERSION = alpine-11
 export NAMESPACE = finanzas
 
 # limpia todo

+ 1 - 1
Makefile

@@ -2,7 +2,7 @@ install:
 
 	echo "Creando imagen con version '${IMG_VERSION}' en el registry '${REGISTRY}'"
 
-	docker build --no-cache -t ${REGISTRY}/finanzas:${IMG_VERSION} -f Dockerfile .
+	docker build --no-cache -t ${REGISTRY}/finanzas:${IMG_VERSION} -f Dockerfile.alpine .
 	docker push ${REGISTRY}/finanzas:${IMG_VERSION}
 
 

+ 0 - 39
src/config/entrypoint-alpine.sh

@@ -1,39 +0,0 @@
-#!/bin/bash
-RUN_PORT="8000"
-
-if [ "$DATABASE" = "postgres" ]
-then
-    echo "Esperando a postgres..."
-
-    while ! nc -z $SQL_HOST $SQL_PORT; do
-      sleep 0.1
-    done
-
-    echo "PostgreSQL ha arrancado"
-
-	python manage.py migrate --no-input
-	python manage.py collectstatic --no-input
-
-	#/opt/venv/bin/gunicorn cartera_acciones.wsgi:application --bind "0.0.0.0:${RUN_PORT}" --daemon
-
-  # Start nginx as a daemon so it doesn't block, then run gunicorn in
-  # foreground (PID 1) so logs go to stdout/stderr and are visible to kubectl logs
-  nginx
-
-  # Determine log level
-  if [ "$DEBUG" = "True" ] || [ "$DEBUG" = "1" ]; then
-    LOG_LEVEL=debug
-  else
-    LOG_LEVEL=info
-  fi
-
-  echo "Lanzando gunicorn con log level: $LOG_LEVEL"
-
-  exec gunicorn misfinanzas.wsgi:application \
-    --bind "0.0.0.0:${RUN_PORT}" \
-    --access-logfile - \
-    --error-logfile - \
-    --log-level "$LOG_LEVEL"
-else
-    echo "la base de datos no es postgres: '$DATABASE'"
-fi

+ 3 - 5
src/config/entrypoint.sh

@@ -1,8 +1,6 @@
 #!/bin/bash
 RUN_PORT="8000"
 
-export PATH=/opt/venv/bin:$PATH
-
 if [ "$DATABASE" = "postgres" ]
 then
     echo "Esperando a postgres..."
@@ -13,8 +11,8 @@ then
 
     echo "PostgreSQL ha arrancado"
 
-	/opt/venv/bin/python manage.py migrate --no-input
-	/opt/venv/bin/python manage.py collectstatic --no-input
+	python manage.py migrate --no-input
+	python manage.py collectstatic --no-input
 
 	#/opt/venv/bin/gunicorn cartera_acciones.wsgi:application --bind "0.0.0.0:${RUN_PORT}" --daemon
 
@@ -31,7 +29,7 @@ then
 
   echo "Lanzando gunicorn con log level: $LOG_LEVEL"
 
-  exec /opt/venv/bin/gunicorn misfinanzas.wsgi:application \
+  exec gunicorn misfinanzas.wsgi:application \
     --bind "0.0.0.0:${RUN_PORT}" \
     --access-logfile - \
     --error-logfile - \