From e0651bd04cdfa78cc9a4cf949b7e1f9724e809b9 Mon Sep 17 00:00:00 2001 From: Chris Lindelof Date: Tue, 20 Aug 2024 02:37:44 -0400 Subject: [PATCH] Initial Docker set up. --- .getignore | 2 -- Dockerfile | 2 -- Fleet-Management.yaml | 23 +++++++++++++++++++++++ back-end/Dockerfile | 11 +++++++++++ back-end/app/__init__.py | 0 back-end/app/main.py | 7 +++++++ front-end/Dockerfile | 18 ++++++++++++++++++ 7 files changed, 59 insertions(+), 4 deletions(-) delete mode 100644 .getignore delete mode 100644 Dockerfile create mode 100644 back-end/Dockerfile create mode 100644 back-end/app/__init__.py create mode 100644 back-end/app/main.py create mode 100644 front-end/Dockerfile diff --git a/.getignore b/.getignore deleted file mode 100644 index b665c99..0000000 --- a/.getignore +++ /dev/null @@ -1,2 +0,0 @@ -.env -sql-data/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 2a22813..0000000 --- a/Dockerfile +++ /dev/null @@ -1,2 +0,0 @@ -FROM python:latest - diff --git a/Fleet-Management.yaml b/Fleet-Management.yaml index e69de29..14f2d3f 100644 --- a/Fleet-Management.yaml +++ b/Fleet-Management.yaml @@ -0,0 +1,23 @@ +services: + front-end: + container_name: front-end + build: ./front-end/Dockerfile + ports: + - 2500:80 + back-end: + container_name: back-end + build: ./back-end/Dockerfile + ports: + - 2501:80 + db: + container_name: fleet-db + image: mysql:9.0.1 + environment: + MYSQL_DATABASE: 'fleetmanagement' + MYSQL_USER: {fleetmanagement-user} + MYSQL_PASSWORD: {fleetmanagement-pass} + MYSQL_ROOT_PASSWORD: {fleetmanagent-root} + ports: + - 3306:3306 + volumes: + - ./sql-data:/var/lib/mysql diff --git a/back-end/Dockerfile b/back-end/Dockerfile new file mode 100644 index 0000000..25b1c84 --- /dev/null +++ b/back-end/Dockerfile @@ -0,0 +1,11 @@ +FROM python:3.9 + +WORKDIR /code + +COPY ./requirements.txt /code/requirements.txt + +RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt + +COPY ./app /code/app + +CMD ["fastapi", "run", "app/main.py", "--proxy-headers", "--port", "80"] diff --git a/back-end/app/__init__.py b/back-end/app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/back-end/app/main.py b/back-end/app/main.py new file mode 100644 index 0000000..2f90c82 --- /dev/null +++ b/back-end/app/main.py @@ -0,0 +1,7 @@ +from fastapi import FastAPI + +app = FastAPI() + +@app.get("/") +async def root(): + return {"message": "Hello World!"} \ No newline at end of file diff --git a/front-end/Dockerfile b/front-end/Dockerfile new file mode 100644 index 0000000..dfb3da0 --- /dev/null +++ b/front-end/Dockerfile @@ -0,0 +1,18 @@ +FROM node:latest AS builder + +ENV NODE_ENV production + +WORKDIR /app + +COPY package.json . + +RUN npm install + +COPY . . + +RUN npm run build + +FROM httpd:latest as production +ENV NODE_ENV production + +COPY --from=builder /app/build/ /usr/local/apache2/htdocs/ \ No newline at end of file