diff --git a/Backend/Dockerfile b/Backend/Dockerfile new file mode 100644 index 00000000..fa42fbfa --- /dev/null +++ b/Backend/Dockerfile @@ -0,0 +1,19 @@ +# syntax=docker/dockerfile:1 + +#base image +FROM python:3.9 + +# +WORKDIR /code + +# +COPY ./requirements.txt /code/requirements.txt + +# +RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt + +# +COPY . /code/app + +# +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"] diff --git a/Backend/config/config.json b/Backend/config/config.json new file mode 100644 index 00000000..da89d054 --- /dev/null +++ b/Backend/config/config.json @@ -0,0 +1,16 @@ +{ + "listeners": { + "*:80": { + "pass": "applications/fastapi" + } + }, + + "applications": { + "fastapi": { + "type": "python 3.9", + "path": "/build/app/", + "module": "app.main", + "callable": "app" + } + } +} \ No newline at end of file diff --git a/Backend/requirements.txt b/Backend/requirements.txt index 8a95427a..3a7a758d 100644 --- a/Backend/requirements.txt +++ b/Backend/requirements.txt @@ -56,7 +56,7 @@ pytest==7.2.0 python-dateutil==2.8.1 python-multipart==0.0.5 pytz==2022.1 -pywin32==227 +#pywin32==227 pywinpty==0.5.7 pyzmq==18.1.1 qtconsole==4.6.0 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..308baa3c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,66 @@ +version: '3.9' + +services: + backend: + build: + context: ./Backend + volumes: + - type: bind + source: ./Backend + target: /app + networks: + - appnet + environment: + DB_HOST: db + DB_PORT: 5432 + DB_USER: postgres + DB_PASSWORD: postgres + DB_NAME: postgres + ports: + - "8001:8001" + depends_on: + - db + + #frontend + frontend: + build: + context: ./frontend + ports: + - "3001:3000" + networks: + - appnet + restart: always + + # database + db: + image: postgres:latest + restart: always + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + ports: + - 5432:5432 + volumes: + - db:/var/lib/postgresql/data + networks: + - appnet + +# used to have a UI for the database + adminer: + image: adminer + restart: always + depends_on: + - db + ports: + - 8081:8080 + networks: + - appnet + +# link all docker containers to the same image +networks: + appnet: + driver: bridge +# bind volumes +volumes: + db: + driver: local diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 00000000..432e6b05 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,20 @@ +# syntax=docker/dockerfile:1 +# This image is based on the popular Alpine Linux project, available in the alpine official image. Alpine Linux is much smaller than most distribution base images (~5MB), and thus leads to much slimmer images in general. +ARG NODE_IMAGE_VERSION=19-alpine3.15 +FROM node:current-alpine +ENV NODE_ENV=production +LABEL name='Chidubem' email='dubemnwabuisi@gmail.com' + +# Create a working directory for Docker to use +WORKDIR /app + +# Copy any file dependecies to the image +COPY package*.json ./ + +# Install app dependencies +RUN yarn install --production + +# Bundle app source +COPY . . +CMD ["yarn", "start"] +EXPOSE 3000 \ No newline at end of file