forked from TDTP/admin_transporte_backend
se actualiza readme.md con instrucciones de docker
parent
141428ce57
commit
1e6cdd8855
260
readme.md
260
readme.md
|
@ -68,6 +68,50 @@ gunzip -c "$LASTFILEDUMP" | psql -U postgres "$POSTGRES_DB"
|
|||
~~~
|
||||
|
||||
|
||||
# archivo para compilar imagen: Dockerfile
|
||||
|
||||
~~~docker
|
||||
# seccion frontend
|
||||
FROM node:20-alpine as frontend
|
||||
ARG gitusername
|
||||
ARG gitpassword
|
||||
|
||||
# soluciona error en descarga de repositorio
|
||||
RUN sed -i 's/https\:\/\//http\:\/\//g' /etc/apk/repositories
|
||||
|
||||
# descargar proyecto
|
||||
RUN apk update && apk add git
|
||||
RUN git clone "https://${gitusername}:${gitpassword}@gitlab.com/m3f_usm/admin_transporte/frontend" /frontend
|
||||
RUN git clone "https://${gitusername}:${gitpassword}@gitlab.com/m3f_usm/admin_transporte/backend" /backend
|
||||
RUN rm -rf /backend/project/dist
|
||||
|
||||
# compilar
|
||||
WORKDIR /frontend
|
||||
RUN npm install && npm run build
|
||||
|
||||
# seccion final -- se omite git y archivos innecerarios para reducir imagen
|
||||
FROM python:3.11-alpine
|
||||
COPY --from=frontend /backend/project/ /app/project
|
||||
COPY --from=frontend /backend/readme.md /app
|
||||
COPY --from=frontend /backend/requirements.txt /app
|
||||
COPY --from=frontend /frontend/dist/ /app/project/dist
|
||||
|
||||
WORKDIR /app
|
||||
RUN pip install -r requirements.txt
|
||||
ENTRYPOINT ["python3"]
|
||||
CMD [ "/app/project/manage.py", "runserver", "0.0.0.0:4000" ]
|
||||
~~~
|
||||
|
||||
# instrucciones para compilar archivo Dockerfile
|
||||
|
||||
~~~bash
|
||||
docker build -t <tagname:version> -f Dockerfile --build-arg gitusername=<usuario gitlab> --build-arg gitpassword=<password gitlab> .
|
||||
|
||||
# ejemplo
|
||||
# docker build -t transporte:v1.2 -f Dockerfile --build-arg gitusername=johndoe --build-arg gitpassword=mypassword .
|
||||
~~~
|
||||
|
||||
|
||||
# archivo produccion: docker-compose.yml
|
||||
|
||||
~~~yml
|
||||
|
@ -76,25 +120,126 @@ name: transporte
|
|||
|
||||
services:
|
||||
|
||||
transporte:
|
||||
image: transporte:v1.2
|
||||
depends_on:
|
||||
- db
|
||||
environment:
|
||||
- PORT=4000
|
||||
ports:
|
||||
- 4000:4000
|
||||
volumes:
|
||||
- ./uploads:/uploads
|
||||
#- .env.prod:/app/.env # (opcional: indicar conexiones a base datos en otro servidor)
|
||||
|
||||
db:
|
||||
image: postgis/postgis:14-3.4-alpine
|
||||
volumes:
|
||||
- db:/var/lib/postgresql/data
|
||||
- ./dumps:/dumps
|
||||
- ./restore_db.sh:/docker-entrypoint-initdb.d/02_restore_db.sh
|
||||
ports:
|
||||
- 5432:5432
|
||||
environment:
|
||||
POSTGRES_PASSWORD: password
|
||||
POSTGRES_DB: transporte
|
||||
PGDATA: /var/lib/postgresql/data/pgdata
|
||||
|
||||
proto:
|
||||
image: python:3.11-alpine
|
||||
environment:
|
||||
- DB_REDIS_HOST=dbproto
|
||||
- DB_REDIS_PORT=6379
|
||||
- TZ=America/Santiago
|
||||
volumes:
|
||||
- ./proto:/app
|
||||
- venv_proto:/root/venv
|
||||
working_dir: /app
|
||||
command: sh -c "
|
||||
[ -d /root/venv/bin ] || ( \
|
||||
python -m venv /root/venv/ \
|
||||
&& . /root/venv/bin/activate \
|
||||
&& pip install -r requirements.txt \
|
||||
) ;
|
||||
|
||||
. /root/venv/bin/activate ;
|
||||
|
||||
cd /app ;
|
||||
[ -f .env ] || ( [ -f .env.develop ] && cp .env.develop .env ) ;
|
||||
watch -n 30 -t python main.py
|
||||
"
|
||||
|
||||
dbproto:
|
||||
image: redis:7.2-alpine
|
||||
volumes:
|
||||
- dbredis:/data
|
||||
|
||||
dbmongo:
|
||||
image: mongo:jammy
|
||||
volumes:
|
||||
- dbmongo:/data/db
|
||||
- dbmongoconfig:/data/configdb
|
||||
ports:
|
||||
- 27017:27017
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: root
|
||||
MONGO_INITDB_ROOT_PASSWORD: password
|
||||
|
||||
|
||||
volumes:
|
||||
db:
|
||||
dbredis:
|
||||
dbmongo:
|
||||
dbmongoconfig:
|
||||
venv_proto:
|
||||
~~~
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
# tunnel para desarrollo
|
||||
|
||||
Ver información en:
|
||||
|
||||
https://gitlab.com/m3f_usm/admin_transporte/backend/-/wikis/home
|
||||
|
||||
|
||||
# archivo desarrollo: docker-compose.yml
|
||||
|
||||
~~~yml
|
||||
version: '3'
|
||||
name: transporte
|
||||
|
||||
services:
|
||||
|
||||
frontend:
|
||||
image: node:18-alpine
|
||||
volumes:
|
||||
- ./frontend:/app
|
||||
ports:
|
||||
- 3000:3000
|
||||
environment:
|
||||
- VITE_PORT=3000
|
||||
- VITE_BACKEND=http://localhost:4000/api
|
||||
working_dir: /app
|
||||
command: sh -c "
|
||||
[ ! -d node_modules ] && npm install ;
|
||||
chmod -R o+w . ;
|
||||
npm run dev
|
||||
"
|
||||
|
||||
backend:
|
||||
image: python:3.11-alpine
|
||||
depends_on:
|
||||
- db
|
||||
environment:
|
||||
- PORT=4000
|
||||
- DBHOST=db
|
||||
- DBPORT=5432
|
||||
- DBNAME=transporte
|
||||
- DBSCHEMA=public
|
||||
- DBUSER=postgres
|
||||
- DBPASS=password
|
||||
- DB_REDIS_HOST=dbproto
|
||||
- DB_REDIS_PORT=6379
|
||||
- SECRET_JWT="kf6Jc!f30Z!1k1N0#!%#"
|
||||
ports:
|
||||
- 4000:4000
|
||||
volumes:
|
||||
- ./transporte:/app
|
||||
- ./backend:/app
|
||||
- ./uploads:/uploads
|
||||
- venv:/root/venv
|
||||
working_dir: /app
|
||||
command: sh -c "
|
||||
|
@ -152,93 +297,30 @@ services:
|
|||
|
||||
dbproto:
|
||||
image: redis:7.2-alpine
|
||||
volumes:
|
||||
- dbredis:/data
|
||||
|
||||
dbmongo:
|
||||
image: mongo:jammy
|
||||
volumes:
|
||||
- dbmongo:/data/db
|
||||
- dbmongoconfig:/data/configdb
|
||||
ports:
|
||||
- 27017:27017
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: root
|
||||
MONGO_INITDB_ROOT_PASSWORD: password
|
||||
|
||||
|
||||
volumes:
|
||||
db:
|
||||
dbredis:
|
||||
dbmongo:
|
||||
dbmongoconfig:
|
||||
venv:
|
||||
venv_proto:
|
||||
~~~
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
# tunnel para desarrollo
|
||||
|
||||
Ver información en:
|
||||
|
||||
https://gitlab.com/m3f_usm/admin_transporte/backend/-/wikis/home
|
||||
|
||||
|
||||
# archivo desarrollo: docker-compose.yml
|
||||
|
||||
~~~yml
|
||||
version: '3'
|
||||
name: transporte
|
||||
|
||||
services:
|
||||
|
||||
frontend:
|
||||
image: node:18-alpine
|
||||
volumes:
|
||||
- ./frontend:/app
|
||||
ports:
|
||||
- 3000:3000
|
||||
environment:
|
||||
- VITE_PORT=3000
|
||||
- VITE_BACKEND=http://localhost:4000/api
|
||||
working_dir: /app
|
||||
command: sh -c "
|
||||
[ ! -d node_modules ] && npm install ;
|
||||
chmod -R o+w . ;
|
||||
npm run dev
|
||||
"
|
||||
|
||||
backend:
|
||||
image: python:3.11-alpine
|
||||
depends_on:
|
||||
- db
|
||||
environment:
|
||||
- PORT=4000
|
||||
- DBHOST=db
|
||||
- DBPORT=5432
|
||||
- DBNAME=transporte
|
||||
- DBSCHEMA=public
|
||||
- DBUSER=postgres
|
||||
- DBPASS=password
|
||||
- DB_REDIS_HOST=dbproto
|
||||
- DB_REDIS_PORT=6379
|
||||
- SECRET_JWT="kf6Jc!f30Z!1k1N0#!%#"
|
||||
ports:
|
||||
- 4000:4000
|
||||
volumes:
|
||||
- ./transporte:/app
|
||||
- venv:/root/venv
|
||||
working_dir: /app
|
||||
command: sh -c "
|
||||
[ -d /root/venv/bin ] || ( \
|
||||
python -m venv /root/venv/ \
|
||||
&& . /root/venv/bin/activate \
|
||||
&& pip install -r requirements.txt \
|
||||
) ;
|
||||
|
||||
. /root/venv/bin/activate ;
|
||||
|
||||
cd /app ;
|
||||
[ -d project ] || django-admin startproject project ;
|
||||
[ -f .env ] || ( [ -f .env.develop ] && cp .env.develop .env ) ;
|
||||
chmod -R o+w project/ ;
|
||||
python project/manage.py runserver 0.0.0.0:$$PORT
|
||||
"
|
||||
extra_hosts:
|
||||
- db:<direccion ip de tu computador>
|
||||
|
||||
|
||||
volumes:
|
||||
venv:
|
||||
~~~
|
||||
|
||||
|
||||
# Script para levantar aplicacion python sin docker
|
||||
|
||||
|
|
Loading…
Reference in New Issue