Dockerfile 900 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Build frontend dist.
  2. FROM node:20-alpine AS frontend
  3. WORKDIR /frontend-build
  4. COPY . .
  5. WORKDIR /frontend-build/web
  6. RUN corepack enable && pnpm i --frozen-lockfile
  7. RUN pnpm build
  8. # Build backend exec file.
  9. FROM golang:1.23-alpine AS backend
  10. WORKDIR /backend-build
  11. COPY . .
  12. COPY --from=frontend /frontend-build/web/dist /backend-build/server/router/frontend/dist
  13. RUN CGO_ENABLED=0 go build -o memos ./bin/memos/main.go
  14. # Make workspace with above generated files.
  15. FROM alpine:latest AS monolithic
  16. WORKDIR /usr/local/memos
  17. RUN apk add --no-cache tzdata
  18. ENV TZ="UTC"
  19. COPY --from=backend /backend-build/memos /usr/local/memos/
  20. COPY entrypoint.sh /usr/local/memos/
  21. EXPOSE 5230
  22. # Directory to store the data, which can be referenced as the mounting point.
  23. RUN mkdir -p /var/opt/memos
  24. VOLUME /var/opt/memos
  25. ENV MEMOS_MODE="prod"
  26. ENV MEMOS_PORT="5230"
  27. ENTRYPOINT ["./entrypoint.sh", "./memos"]