Fix Containerfile and add build workflow
This commit is contained in:
parent
14f4e87d9d
commit
2829053576
8 changed files with 92 additions and 973 deletions
34
.forgejo/workflows/build.yaml
Normal file
34
.forgejo/workflows/build.yaml
Normal file
|
@ -0,0 +1,34 @@
|
|||
name: "Build"
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: "docker"
|
||||
container:
|
||||
image: "code.forgejo.org/oci/node:22-alpine"
|
||||
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
uses: "https://code.forgejo.org/actions/checkout@v4"
|
||||
|
||||
- name: "Install Docker"
|
||||
run: |
|
||||
apk add docker
|
||||
|
||||
- name: "Login to the container registry"
|
||||
uses: "https://code.forgejo.org/docker/login-action@v3"
|
||||
with:
|
||||
registry: "git.moritzruth.de"
|
||||
username: "moritzruth"
|
||||
password: "${{ secrets.PACKAGES_TOKEN }}"
|
||||
|
||||
- name: "Build and push the container image"
|
||||
uses: "https://code.forgejo.org/docker/build-push-action@v6"
|
||||
with:
|
||||
context: "."
|
||||
file: "./Containerfile"
|
||||
push: true
|
||||
tags: "git.moritzruth.de/moritzruth/twenty-one:latest"
|
22
Containerfile
Normal file
22
Containerfile
Normal file
|
@ -0,0 +1,22 @@
|
|||
FROM node:22-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN npm install --global pnpm
|
||||
RUN pnpm install --frozen-lockfile
|
||||
RUN pnpm build
|
||||
|
||||
FROM node:22-alpine
|
||||
RUN npm install --global pnpm
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/package.json /app/
|
||||
COPY --from=builder /app/pnpm-lock.yaml /app/
|
||||
COPY --from=builder /app/tsconfig.json /app/
|
||||
COPY --from=builder /app/backend /app/backend
|
||||
COPY --from=builder /app/shared /app/shared
|
||||
COPY --from=builder /app/dist /app/dist
|
||||
RUN pnpm install --frozen-lockfile --prod
|
||||
|
||||
EXPOSE 3000
|
||||
ENV NODE_ENV=production
|
||||
ENTRYPOINT ["pnpm", "start"]
|
15
Dockerfile
15
Dockerfile
|
@ -1,15 +0,0 @@
|
|||
FROM node:18-alpine
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN npm install --global pnpm
|
||||
RUN pnpm install --frozen-lockfile
|
||||
RUN pnpm build:ui
|
||||
RUN mkdir -p /data
|
||||
|
||||
EXPOSE 4000
|
||||
EXPOSE 3000
|
||||
VOLUME /data
|
||||
ENV DATABASE_FILE=file:/data/twentyone.db
|
||||
|
||||
ENTRYPOINT ["pnpm"]
|
||||
CMD ["start:ui"]
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
> The game of Twenty-one, in the browser, with online-multiplayer and special cards
|
||||
|
||||
▶ [**twentyone.deltaa.xyz**](https://twentyone.deltaa.xyz)
|
||||
▶ [**twenty-one.deltaa.xyz**](https://twenty-one.deltaa.xyz)
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import createExpressApp from "express"
|
||||
import createExpressApp, { static as staticMiddleware } from "express"
|
||||
import { listen } from "listhen"
|
||||
import { WebSocketServer } from "ws"
|
||||
import { appRouter } from "./trpc"
|
||||
|
@ -8,6 +8,7 @@ import { createContext } from "./trpc/base"
|
|||
import cookieParser from "cookie-parser"
|
||||
import { parse as parseCookie } from "cookie"
|
||||
import { isDev } from "./isDev"
|
||||
import { resolve } from "node:path"
|
||||
|
||||
const expressApp = createExpressApp()
|
||||
expressApp.use(cookieParser())
|
||||
|
@ -17,6 +18,8 @@ expressApp.use("/trpc", createTrpcMiddleware({
|
|||
createContext: ({ req, res }) => createContext(req.cookies.token ?? null, res),
|
||||
}))
|
||||
|
||||
if (!isDev) expressApp.use(staticMiddleware(resolve(import.meta.dirname, "../dist")))
|
||||
|
||||
const { server } = await listen(expressApp, { isProd: !isDev, autoClose: false })
|
||||
|
||||
const wss = new WebSocketServer({ server, path: "/ws" })
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "twentyone",
|
||||
"name": "twenty-one",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
@ -16,12 +16,10 @@
|
|||
"@types/ws": "^8.5.14",
|
||||
"@vitejs/plugin-vue": "^5.2.1",
|
||||
"sass": "^1.85.1",
|
||||
"tsx": "^4.19.3",
|
||||
"typescript": "^5.8.2",
|
||||
"unocss": "66.1.0-beta.3",
|
||||
"unplugin-icons": "^22.1.0",
|
||||
"vite": "^6.2.0",
|
||||
"windicss": "^3.5.6"
|
||||
"vite": "^6.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fontsource-variable/inter": "^5.2.5",
|
||||
|
@ -30,6 +28,7 @@
|
|||
"@trpc/client": "^10.45.2",
|
||||
"@trpc/server": "^10.45.2",
|
||||
"@types/cookie-parser": "^1.4.8",
|
||||
"@unocss/preset-wind3": "66.1.0-beta.3",
|
||||
"@vueuse/core": "^12.7.0",
|
||||
"@vueuse/integrations": "^12.7.0",
|
||||
"bufferutil": "^4.0.9",
|
||||
|
@ -44,6 +43,7 @@
|
|||
"modern-normalize": "^3.0.1",
|
||||
"nanoid": "^5.1.2",
|
||||
"pinia": "^3.0.1",
|
||||
"tsx": "^4.19.3",
|
||||
"vue": "^3.5.13",
|
||||
"vue-router": "^4.5.0",
|
||||
"ws": "^8.18.1",
|
||||
|
|
975
pnpm-lock.yaml
generated
975
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
import { defineConfig, presetWind } from "unocss"
|
||||
import colors from "windicss/colors"
|
||||
import { defineConfig } from "unocss"
|
||||
import { presetWind, colors } from "@unocss/preset-wind3"
|
||||
|
||||
export default defineConfig({
|
||||
presets: [
|
||||
|
|
Loading…
Add table
Reference in a new issue