move everything to a dockerfile instead of complicated system lol
This commit is contained in:
parent
ea4b462a5f
commit
cd62fc4f67
|
@ -0,0 +1,11 @@
|
|||
**/node_modules
|
||||
build
|
||||
data
|
||||
**/dist
|
||||
packages/build
|
||||
Dockerfile
|
||||
|
||||
# dotfiles
|
||||
.git*
|
||||
.vscode
|
||||
**/.env*
|
|
@ -18,5 +18,7 @@ node_modules/
|
|||
*.tsbuildinfo
|
||||
.eslintcache
|
||||
|
||||
# only ignore .env in root because Vite requires some things (check packages/admin)
|
||||
/.env
|
||||
.env.local
|
||||
dist
|
|
@ -0,0 +1,80 @@
|
|||
FROM node:20-alpine AS base
|
||||
|
||||
#
|
||||
# === BUILDER ===
|
||||
#
|
||||
|
||||
FROM base as build
|
||||
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
|
||||
WORKDIR /home/node/app
|
||||
COPY --chown=node:node . .
|
||||
|
||||
USER node
|
||||
RUN npm install --include=dev
|
||||
|
||||
# --- build lib ---
|
||||
|
||||
RUN npm -w packages/lib run build
|
||||
# janky? fix to keep imports in dev
|
||||
RUN sed -i -e 's/"main": ".*"/"main": ".\/dist\/index.js"/' packages/lib/package.json
|
||||
|
||||
# --- build main client ---
|
||||
|
||||
RUN npm -w packages/client run build
|
||||
|
||||
# --- build admin ---
|
||||
|
||||
RUN npm -w packages/admin run build
|
||||
|
||||
# --- build server ---
|
||||
|
||||
RUN npx -w packages/server prisma generate
|
||||
RUN npm -w packages/server run build
|
||||
|
||||
#
|
||||
# === RUNNER ===
|
||||
#
|
||||
|
||||
FROM base as run
|
||||
WORKDIR /home/node/app
|
||||
COPY package*.json docker-start.sh ./
|
||||
|
||||
# --- prepare lib ---
|
||||
|
||||
RUN mkdir -p packages/lib
|
||||
COPY --from=build /home/node/app/packages/lib/package.json ./packages/lib
|
||||
COPY --from=build /home/node/app/packages/lib/dist ./packages/lib/dist
|
||||
|
||||
# --- prepare client ---
|
||||
|
||||
RUN mkdir -p packages/client
|
||||
COPY --from=build /home/node/app/packages/client/dist ./packages/client/
|
||||
|
||||
# --- prepare admin ---
|
||||
|
||||
RUN mkdir -p packages/admin
|
||||
COPY --from=build /home/node/app/packages/admin/dist ./packages/admin/
|
||||
|
||||
# --- prepare server ---
|
||||
|
||||
RUN mkdir -p packages/server
|
||||
COPY --from=build /home/node/app/packages/server/package.json ./packages/server/
|
||||
COPY --from=build /home/node/app/packages/server/prisma ./packages/server/prisma
|
||||
COPY --from=build /home/node/app/packages/server/tool.sh ./packages/server/
|
||||
COPY --from=build /home/node/app/packages/server/dist ./packages/server/dist
|
||||
|
||||
# --- finalize ---
|
||||
|
||||
RUN npm install --omit=dev
|
||||
RUN npx -w packages/server prisma generate
|
||||
|
||||
# set runtime env variables
|
||||
|
||||
ENV PORT 3000
|
||||
ENV NODE_ENV production
|
||||
ENV SERVE_CLIENT /home/node/app/packages/client
|
||||
ENV SERVE_ADMIN /home/node/app/packages/admin
|
||||
|
||||
EXPOSE 3000
|
||||
ENTRYPOINT [ "/bin/sh" ]
|
||||
CMD [ "./docker-start.sh" ]
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
## Running via Docker Compose
|
||||
|
||||
1. Run `npm run build:all`
|
||||
2. Run `npm run build:docker`
|
||||
3. Run `docker compose run --rm canvas npx prisma migrate deploy`
|
||||
4. (optional) Load default palette colors
|
||||
1. Run `docker compose build`
|
||||
2. (optional) Load default palette colors
|
||||
Run `docker compose run --rm canvas npm run -w packages/server prisma:seed:palette`
|
||||
5. Run `docker compose up -d`
|
||||
3. Run `docker compose up -d`
|
||||
|
|
|
@ -6,12 +6,16 @@ name: canvas
|
|||
services:
|
||||
canvas:
|
||||
image: sc07/canvas
|
||||
build: .
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
- SESSION_SECRET=CHANGE ME TO RANDOM VALUE
|
||||
- REDIS_HOST=redis://redis
|
||||
- DATABASE_URL=postgres://postgres@postgres/canvas
|
||||
- AUTH_ENDPOINT=https://auth.fediverse.events
|
||||
- AUTH_CLIENT=canvas
|
||||
- AUTH_SECRET=${AUTH_SECRET}
|
||||
depends_on:
|
||||
- redis
|
||||
- postgres
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
# This script runs when the docker image starts
|
||||
# It just forces all migrations to run and then starts lol
|
||||
|
||||
npx -w packages/server npx prisma migrate deploy
|
||||
npm -w packages/server run start
|
Loading…
Reference in New Issue