From 6a110c2bbde913adbb14cc08d3e9d92f5e0f59dc Mon Sep 17 00:00:00 2001 From: jableader Date: Sat, 21 Sep 2024 11:02:10 +1000 Subject: [PATCH] Initial commit --- .gitignore | 4 ++++ Dockerfile | 20 ++++++++++++++++++++ build-local.sh | 5 +++++ build-remote.sh | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100755 build-local.sh create mode 100755 build-remote.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..956f837 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/munch-ease-backend +/munch-ease-frontend +/munch-ease-backend-buildartifact +/munch-ease-frontend-buildartifact \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4bc71b9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM python:3.11 + +ARG FRONTEND_DIR=munch-ease-frontend +ARG BACKEND_DIR=munch-ease-backend + +WORKDIR /code + +COPY ${BACKEND_DIR}/requirements.txt /code/requirements.txt +RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt + +COPY ${BACKEND_DIR} /code/app +COPY ${FRONTEND_DIR}/dist /code/app/front-dist + +# Set production flag +ENV DOOF_PROD=1 + +EXPOSE 80 +WORKDIR /code/app + +CMD python -m uvicorn main:app --host 0.0.0.0 --port 80 \ No newline at end of file diff --git a/build-local.sh b/build-local.sh new file mode 100755 index 0000000..c8c8d9d --- /dev/null +++ b/build-local.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +(cd ./front && npm install && npm run build) + +docker build -t doof . \ No newline at end of file diff --git a/build-remote.sh b/build-remote.sh new file mode 100755 index 0000000..a8d24e1 --- /dev/null +++ b/build-remote.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Stop on error +set -e + +# Clone the munch-ease-frontend & munch-ease-backend repos +# from https://git.jacobsthings.dynu.net/jacob/munch-ease-frontend.git +# and https://git.jacobsthings.dynu.net/jacob/munch-ease-backend.git +# respectively + +if [ -d ./munch-ease-frontend-buildartifact ]; then + rm -rf ./munch-ease-frontend-buildartifact +fi + +if [ -d ./munch-ease-backend-buildartifact ]; then + rm -rf ./munch-ease-backend-buildartifact +fi + +git clone https://git.jacobsthings.dynu.net/jacob/munch-ease-frontend.git ./munch-ease-frontend-buildartifact +git clone https://git.jacobsthings.dynu.net/jacob/munch-ease-backend.git ./munch-ease-backend-buildartifact + +# Build the frontend via docker node:16 +docker run -v "$(pwd)/munch-ease-frontend-buildartifact:/tmp/munch-ease/frontend" node:16 /bin/bash -c "cd /tmp/munch-ease/frontend && npm install && npm run build" + +# Build the container, setting the FRONTEND_DIR and BACKEND_DIR args +docker build -t doof --build-arg FRONTEND_DIR=./munch-ease-frontend-buildartifact --build-arg BACKEND_DIR=./munch-ease-backend-buildartifact . + +if [ -d ./munch-ease-frontend-buildartifact ]; then + rm -rf ./munch-ease-frontend-buildartifact +fi + +if [ -d ./munch-ease-backend-buildartifact ]; then + rm -rf ./munch-ease-backend-buildartifact +fi \ No newline at end of file