Skip to content

Commit

Permalink
chore: update docker file to multi stage builds
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Mar 7, 2024
1 parent 1872a5d commit ebc91d9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
37 changes: 29 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
FROM node:20-alpine
# tianji reporter
FROM golang:1.21.1-bookworm AS reporter
WORKDIR /app/reporter

WORKDIR /app/tianji
COPY ./reporter/ ./reporter/

RUN npm install -g [email protected]
RUN apt update
RUN cd reporter && go build .

COPY . .
# # Base ------------------------------
FROM node:20-alpine AS base

RUN npm install -g [email protected]
RUN apk add --update --no-cache python3 py3-pip g++ make

# Tianji frontend ------------------------------
FROM base AS docker-static
WORKDIR /app/tianji

COPY . .

RUN pnpm install --frozen-lockfile

RUN pnpm build
RUN pnpm build:static

# Tianji server ------------------------------
FROM base AS docker-server
WORKDIR /app/tianji

COPY . .

RUN pnpm install --filter @tianji/server... --config.dedupe-peer-dependents=false

RUN mkdir -p ./src/server/public
RUN COPY --from=docker-static /app/tianji/src/server/public /app/tianji/src/server/public

RUN pnpm build:server

# make sure run after pnpm build completed to avoid break system packages
# Push client(only support pure text message)
RUN pip install apprise --break-system-packages

# remove unused source file
RUN rm -rf ./src/client
RUN rm -rf ./website
RUN rm -rf ./reporter
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"start:docker:db": "cd src/server && pnpm db:migrate:apply && pnpm db:migrate:script",
"test": "vitest",
"build": "pnpm build:tracker && pnpm build:app && pnpm build:geo",
"build:static": "pnpm build:tracker && pnpm build:client && pnpm build:geo",
"build:app": "pnpm build:server && pnpm build:client",
"build:client": "cd src/client && pnpm build",
"build:server": "cd src/server && pnpm build",
Expand Down

0 comments on commit ebc91d9

Please sign in to comment.