diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a157c89 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +# Change this as necessary for your own project(s) +Containerfile* +README.md +node_modules +*/node_modules +*.log +.dockerignore +.env* +mysqldata* +.vscode +.github +.git diff --git a/Containerfile.database b/Containerfile.database new file mode 100644 index 0000000..f4072e3 --- /dev/null +++ b/Containerfile.database @@ -0,0 +1,11 @@ +FROM mysql/mysql-server:latest as base + +VOLUME ./mysqldata /var/lib/mysql + +ENV MYSQL_ROOT_PASSWORD=root_pw +ENV MYSQL_ROOT_HOST=% +ENV MYSQL_USER=infodb_user +ENV MYSQL_PASSWORD=infodb_pw_123 +ENV MYSQL_DATABASE=infodb + +EXPOSE 3306 diff --git a/Containerfile.server b/Containerfile.server new file mode 100644 index 0000000..b3ea396 --- /dev/null +++ b/Containerfile.server @@ -0,0 +1,27 @@ +FROM node:alpine as base + +WORKDIR /usr/src/app + +# Copy in package.json and package-lock.json +COPY --chown=1001:1001 package*.json ./ + +# Install dependencies and devDependencies +RUN npm ci --omit=dev + +# Copy in source code and other assets +COPY --chown=1001:1001 . . + +# Compile the source TS into JS files +# RUN npm run build:ts + +# Configure fastify behaviour, and NODE_ENV +ENV NODE_ENV=production +ENV JWT_ACCESS_SECRET=SECRET123 +ENV JWT_REFRESH_SECRET=ANOTHER_SECRET123 +ENV DATABASE_URL=mysql://infodb_user:infodb_pw_123@localhost:3306/infodb + +EXPOSE 3000 + +RUN npx prisma generate + +CMD ["npm", "run", "start:migrate"] diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..9758b15 --- /dev/null +++ b/install.sh @@ -0,0 +1,7 @@ +podman pod create --name scheduler-demo-pod --publish=3306:3306,3000:3000 && +podman build . -f ./Containerfile.server -t scheduler-demo-server && +podman build . -f ./Containerfile.database -t scheduler-demo-db && + +podman run -dit --pod=scheduler-demo-pod --name=scheduler-demo-db-1 scheduler-demo-db:latest && +podman run -dit --pod=scheduler-demo-pod --name=scheduler-demo-server-1 scheduler-demo-server:latest +