Add Docker support

- Add Dockerfile for prod selfhost
- Add dev Dockerfile for use with 'docker compose --profile dev watch'
- Include compose.yml
- Update readme with selfhost instructions
- Added 'npm run start:dev:docker' for running synced watched container
pull/98/head
ceramicwhite 2024-04-12 03:38:23 -07:00
parent 20b6612cd1
commit b810dd4f25
6 changed files with 141 additions and 1 deletions

28
.dockerignore Normal file
View File

@ -0,0 +1,28 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.next
**/.cache
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/build
**/dist
LICENSE
README.md

41
Dockerfile Normal file
View File

@ -0,0 +1,41 @@
# syntax=docker/dockerfile:1
ARG NODE_VERSION=${NODE_VERSION:-18.3.0}
ARG OS=${OS:-alpine}
#####################################
FROM node:${NODE_VERSION}-${OS} as build
ENV VITE_BYPASS_LOGIN=1 \
VITE_BYPASS_TUTORIAL=0 \
NEXT_TELEMETRY_DISABLED=1
WORKDIR /app
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci
COPY . .
RUN npm run build
######################################
FROM node:${NODE_VERSION}-${OS} as app
ENV NODE_ENV=production \
PORT=${PORT:-8000}
RUN npm install --location=global vite
USER node
WORKDIR /app
COPY --from=build /app/dist/ .
COPY --from=build /app/package.json ./package.json
EXPOSE $PORT
CMD npm run start -- --host --port $PORT

26
Dockerfile.dev Normal file
View File

@ -0,0 +1,26 @@
# syntax=docker/dockerfile:1
ARG NODE_VERSION=${NODE_VERSION:-18.3.0}
ARG OS=${OS:-alpine}
######################################
FROM node:${NODE_VERSION}-${OS} as dev
ENV VITE_BYPASS_LOGIN=1 \
VITE_BYPASS_TUTORIAL=0 \
NODE_ENV=development
USER node
WORKDIR /app
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci
COPY --chown=node:node . .
EXPOSE 8000
CMD npm run start:dev -- --host --port 8000

View File

@ -11,7 +11,12 @@ node: 18.3.0
1. Clone the repo and in the root directory run `npm install`
- *if you run into any errors, reach out in the **#dev-corner** channel in discord*
2. Run `npm run start:dev` to locally run the project in `localhost:8000`
2. Run `npm run start:dev` to locally run the project in `localhost:8000` or `npm run start:dev:docker` to run in a docker container
### 🐳 Docker Selfhost
1. Clone the repo and in the root directory run `docker compose up -d`
2. The project will be running on `localhost:8000`
### ❔ FAQ

39
compose.yaml Normal file
View File

@ -0,0 +1,39 @@
services:
web:
build:
context: .
image: pagefaultgames/pokerogue
container_name: pokerogue
init: true
environment:
PORT: 8000
ports:
- 8000:8000
profiles: [""]
dev:
build:
context: .
dockerfile: ./Dockerfile.dev
environment:
NODE_ENV: development
command: npm run start:dev -- --host --port 8000
develop:
watch:
- action: sync
path: ./src
target: /app/src
ignore:
- node_modules/
- action: sync
path: ./public
target: /app/public
ignore:
- node_modules/
- action: rebuild
path: ./package.json
- action: rebuild
path: ./package-lock.json
ports:
- 8000:8000
profiles: ["dev"]

View File

@ -6,6 +6,7 @@
"scripts": {
"start": "vite",
"start:dev": "vite --mode development",
"start:dev:docker": "docker-compose --profile dev watch -d",
"build": "vite build",
"preview": "vite preview",
"test": "vitest run",