Refactor and add docker-compose.yml(s)

This commit is contained in:
Santiago Lo Coco 2023-10-23 12:31:09 -03:00
parent f33da2703b
commit 4fc7781cb5
31 changed files with 53 additions and 43 deletions

View File

@ -8,9 +8,9 @@ repos:
rev: 6.1.0
hooks:
- id: flake8
args: [--config, flights-domain/setup.cfg]
args: [--config, flights-domain/flights-information/setup.cfg]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: ['--src-path', 'flights-domain/']
args: ['--src-path', 'flights-domain/', 'auth-domain/user-manager/']

View File

@ -1,8 +1,6 @@
from flask.cli import FlaskGroup
from src import create_app, db
from src.api.models.users import User
from src import create_app, db
from src.api.models.users import User
app = create_app()
cli = FlaskGroup(create_app=create_app)

View File

@ -1,8 +1,13 @@
FROM node:17.9.1 AS app
ENV REACT_APP_ENDPOINT "https://api.fids.slc.ar/"
WORKDIR /app
COPY package.json /app/package.json
RUN npm install
COPY . .
RUN npm install && npm run build
ARG REACT_APP_ENDPOINT
ENV REACT_APP_ENDPOINT $REACT_APP_ENDPOINT
RUN npm run build
FROM nginx:alpine
WORKDIR /usr/share/nginx/html

View File

@ -0,0 +1,12 @@
version: '3.8'
services:
client:
container_name: fids_browser_client
image: ${CLIENT_IMAGE}
restart: always
ports:
- 8080:80
environment:
- API_HOST=api
network_mode: host

View File

@ -2,12 +2,9 @@ version: '3.8'
services:
api:
container_name: fids_api
flights-api:
container_name: fids_flights_api
image: ${API_IMAGE}
profiles:
- api
- all
ports:
- 5000:5000
healthcheck:
@ -19,20 +16,17 @@ services:
environment:
- TEST_TARGET=${TEST_TARGET}
- PORT=5000
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@api-db/${POSTGRES_DB}
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@flights-api-db/${POSTGRES_DB}
- APP_SETTINGS=${APP_SETTINGS}
depends_on:
api-db:
flights-api-db:
condition: service_healthy
api-db:
container_name: fids_api_db
flights-api-db:
container_name: fids_flights_db
build:
context: ./db
dockerfile: Dockerfile
profiles:
- api
- all
healthcheck:
test: psql postgres --command "select 1" -U ${POSTGRES_USER}
interval: 2s
@ -44,18 +38,3 @@ services:
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASS}
client:
container_name: fids_client
image: ${CLIENT_IMAGE}
profiles:
- client
- all
restart: always
ports:
- 8080:80
depends_on:
api:
condition: service_healthy
environment:
- API_HOST=api

View File

@ -1,6 +1,5 @@
from sqlalchemy.orm import Session
from sqlalchemy.sql import func
from src.api.models.flight import Flight
from src.api.schemas.flight import Flight as FlightPydantic

View File

@ -1,6 +1,5 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from src.api.db import Base, engine
from src.api.routes import flights, health
@ -14,6 +13,9 @@ app.add_middleware(
allow_origins=[
"https://fids.slc.ar",
"http://localhost:8080",
"http://localhost",
"http://localhost:80",
"http://localhost:81",
"http://localhost:3000",
],
allow_credentials=True,

View File

@ -1,6 +1,5 @@
from sqlalchemy import Column, DateTime, Integer, String
from sqlalchemy.sql import func
from src.api.db import Base

View File

@ -2,7 +2,6 @@ from typing import Optional
from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.orm import Session
from src.api.cruds import flight as flight_crud
from src.api.db import get_db
from src.api.schemas.flight import Flight, FlightCreate, FlightStatusUpdate

View File

@ -1,5 +1,4 @@
from fastapi.testclient import TestClient
from src.api.main import Flight, app, flight_instance
client = TestClient(app)

View File

@ -1,8 +1,14 @@
FROM node:17.9.1 AS app
ENV REACT_APP_ENDPOINT "https://api.fids.slc.ar/"
WORKDIR /app
COPY package.json /app/package.json
RUN npm -v && ls -al
RUN npm install
COPY . .
RUN npm install && npm run build
ARG REACT_APP_ENDPOINT
ENV REACT_APP_ENDPOINT $REACT_APP_ENDPOINT
RUN npm run build
FROM nginx:alpine
WORKDIR /usr/share/nginx/html

View File

@ -0,0 +1,12 @@
version: '3.8'
services:
screens-client:
container_name: fids_screens_client
image: ${CLIENT_IMAGE}
restart: always
ports:
- 8080:80
environment:
- API_HOST=api
network_mode: host

View File

@ -1,5 +1,5 @@
server {
listen 80;
listen 81;
location / {
root /usr/share/nginx/html;
index unresolvable-file-html.html;