Add docker setup

This commit is contained in:
Mihkel Martin Kasterpalu 2025-01-21 17:53:19 +02:00
parent 019ec6cbaa
commit ec67134ba7
4 changed files with 54 additions and 1 deletions

2
.dockerignore Normal file
View file

@ -0,0 +1,2 @@
node_modules/
.env

36
Dockerfile Normal file
View file

@ -0,0 +1,36 @@
# Use this image as the platform to build the app
FROM node:20 AS build
# The WORKDIR instruction sets the working directory for everything that will happen next
WORKDIR /app
# Install packages
RUN yarn global add pnpm
ARG CLIENT_ID
ARG CLIENT_SECRET
ARG SESH_SECRET
ENV CLIENT_ID=${CLIENT_ID}
ENV CLIENT_SECRET=${CLIENT_SECRET}
ENV SESH_SECRET=${SESH_SECRET}
COPY package.json .
RUN pnpm i
COPY . .
# Build SvelteKit app
RUN pnpm build
FROM node:20
WORKDIR /app
COPY --from=build /app/build /app/build
COPY --from=build /app/package.json /app/package.json
RUN npm install --omit=dev --legacy-peer-deps
# This is the command that will be run inside the image when you tell Docker to start the container
CMD ["node", "build/index.js"]

15
compose.yml Normal file
View file

@ -0,0 +1,15 @@
---
name: 'stuff.kasterpalu'
services:
web:
container_name: 'stuff.kasterpalu-web'
build:
context: .
args:
ENV CLIENT_ID: $CLIENT_ID
ENV CLIENT_SECRET: $CLIENT_SECRET
ENV SESH_SECRET: $SESH_SECRET
env_file: .env
restart: unless-stopped
ports:
- 9005:3000

View file

@ -1,5 +1,5 @@
{
"name": "minigames",
"name": "stuff.kasterpalu",
"private": true,
"version": "0.0.1",
"type": "module",