Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ RUN chmod +x /code/startup_scripts/entrypoint.sh
WORKDIR /code
ENTRYPOINT ["/code/startup_scripts/entrypoint.sh"]
CMD []
EXPOSE 8000
EXPOSE 8080
8 changes: 6 additions & 2 deletions backend/startup_scripts/create_groups_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@ def create_group(groups, group, user_pool_id):
create_user(cognito_client, user_pool_id, email, group)
print(email + '/Test123! created.')

sql = 'INSERT INTO public.user (email, "firstName", "lastName", "roleId") VALUES (%s, %s, %s, %s) ON CONFLICT(email) DO NOTHING'
create_table = 'CREATE TABLE IF NOT EXISTS public.user (id SERIAL NOT NULL, email varchar(256), "firstName" varchar(256), "lastName" varchar(256), "roleId" integer, PRIMARY KEY (id));'

sql = 'INSERT INTO public.user (email, "firstName", "lastName", "roleId") VALUES (%s, %s, %s, %s)'
url = urlparse(os.environ['DATABASE_URL'])
with psycopg2.connect(database=url.path[1:],
user=url.username,
password=url.password,
host=url.hostname,
port=url.port) as db_conn:
with db_conn.cursor() as cur:
cur.executemany(sql, rows)
cur.execute(create_table)
db_conn.commit()
cur.executemany(sql, rows)
db_conn.commit()
7 changes: 5 additions & 2 deletions backend/startup_scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ if [ -r .env ]; then
fi

# Alembic migration
alembic upgrade head
# alembic upgrade head

if [ "$1" == "prod" ]; then
fastapi run app/main.py --port 8000
else
env | grep COGNITO
# Setup moto server and export Cognito environment variables
python startup_scripts/setup_moto_server.py > envfile
cat envfile
source envfile
rm envfile

env | grep COGNITO
sleep 3
# Create test users in moto server and postgres
python startup_scripts/create_groups_users.py

Expand Down
56 changes: 28 additions & 28 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,34 @@ services:
motoserver:
image: motoserver/moto:latest
ports:
- "5000:5000"
environment:
- MOTO_PORT=5000
backend:
build:
context: ./backend
ports:
- "8000:8000"
environment:
- COGNITO_CLIENT_ID=testing
- COGNITO_CLIENT_SECRET=testing
- COGNITO_REGION=us-east-1
- COGNITO_REDIRECT_URI=http://localhost:4040/signin
- COGNITO_USER_POOL_ID=testing
- COGNITO_ACCESS_ID=testing
- COGNITO_ACCESS_KEY=testing
- COGNITO_ENDPOINT_URL=http://motoserver:5000
- ROOT_URL=http://localhost:4040
- DATABASE_URL=postgresql+psycopg2://postgres:postgres@db:5432/huu
links:
- db
depends_on:
- pgadmin
- motoserver
frontend:
build:
context: ./frontend
ports:
- "6789:5000"
# environment:
# - MOTO_PORT=6789
# backend:
# build:
# context: ./backend
# ports:
# - "8080:8080"
# environment:
# - COGNITO_CLIENT_ID=testing
# - COGNITO_CLIENT_SECRET=testing
# - COGNITO_REGION=us-east-1
# - COGNITO_REDIRECT_URI=http://localhost:4040/signin
# - COGNITO_USER_POOL_ID=testing
# - COGNITO_ACCESS_ID=testing
# - COGNITO_ACCESS_KEY=testing
# - COGNITO_ENDPOINT_URL=http://motoserver:5000
# - ROOT_URL=http://localhost:4040
# - DATABASE_URL=postgresql+psycopg2://postgres:postgres@db:5432/huu
# links:
# - db
# depends_on:
# - pgadmin
# - motoserver
# frontend:
# build:
# context: ./frontend
# ports:
- "4040:80"
volumes:
db-data: {}
Expand Down
3 changes: 0 additions & 3 deletions frontend/.env.example

This file was deleted.

8 changes: 4 additions & 4 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Named temprorary image to build client bundles
FROM node:lts-alpine as builder
ARG VITE_HUU_API_BASE_URL
FROM node:20-alpine as builder
ARG VITE_HUU_API_BASE_URL=http://localhost:8080/api/
ENV VITE_HUU_API_BASE_URL=${VITE_HUU_API_BASE_URL}

# do all copies/builds within a subdirectory
Expand All @@ -19,6 +19,7 @@ FROM cypress/base as development
WORKDIR /app
RUN apt-get update && apt-get install -y curl


# Copy built assets and all source files from builder
COPY --from=builder /app .
RUN npx cypress install
Expand All @@ -41,5 +42,4 @@ RUN if [ -e "nginx.conf" ]; then \
# Default nginx runs on port 80, but we will
# publish to a different port at Docker
# runtime environment level
EXPOSE 80
ENTRYPOINT ["/bin/sh", "-c"]
EXPOSE 80
Loading
Loading