2023-09-18 23:23:13 +08:00
|
|
|
# Build protobuf.
|
|
|
|
FROM golang:1.21-alpine AS protobuf
|
|
|
|
WORKDIR /protobuf-generate
|
2021-12-12 11:43:27 +08:00
|
|
|
|
2023-09-17 20:55:05 +08:00
|
|
|
COPY . .
|
2023-03-18 10:36:53 +08:00
|
|
|
|
2023-09-18 23:23:13 +08:00
|
|
|
RUN GO111MODULE=on GOBIN=/usr/local/bin go install github.com/bufbuild/buf/cmd/buf@v1.26.1
|
2023-09-17 20:55:05 +08:00
|
|
|
|
2023-09-18 23:23:13 +08:00
|
|
|
WORKDIR /protobuf-generate/proto
|
2023-03-18 10:36:53 +08:00
|
|
|
|
2023-09-17 20:55:05 +08:00
|
|
|
RUN buf generate
|
|
|
|
|
2023-09-18 23:23:13 +08:00
|
|
|
# Build frontend dist.
|
|
|
|
FROM node:18-alpine AS frontend
|
|
|
|
WORKDIR /frontend-build
|
|
|
|
|
|
|
|
COPY ./web .
|
|
|
|
|
|
|
|
COPY --from=protobuf /protobuf-generate/web/src/types/proto ./src/types/proto
|
2023-09-17 20:55:05 +08:00
|
|
|
|
|
|
|
RUN corepack enable && pnpm i --frozen-lockfile
|
2021-12-12 11:43:27 +08:00
|
|
|
|
2023-04-16 00:47:40 +08:00
|
|
|
RUN pnpm build
|
2021-12-12 11:43:27 +08:00
|
|
|
|
|
|
|
# Build backend exec file.
|
2023-08-27 16:08:39 +08:00
|
|
|
FROM golang:1.21-alpine AS backend
|
2021-12-12 11:43:27 +08:00
|
|
|
WORKDIR /backend-build
|
|
|
|
|
|
|
|
COPY . .
|
2023-09-18 23:23:13 +08:00
|
|
|
COPY --from=frontend /frontend-build/dist ./server/dist
|
2021-12-12 11:43:27 +08:00
|
|
|
|
2023-05-29 13:29:42 +08:00
|
|
|
RUN CGO_ENABLED=0 go build -o memos ./main.go
|
2021-12-12 11:43:27 +08:00
|
|
|
|
|
|
|
# Make workspace with above generated files.
|
2023-08-27 16:08:39 +08:00
|
|
|
FROM alpine:latest AS monolithic
|
2021-12-12 11:43:27 +08:00
|
|
|
WORKDIR /usr/local/memos
|
|
|
|
|
2023-04-08 17:57:00 +08:00
|
|
|
RUN apk add --no-cache tzdata
|
|
|
|
ENV TZ="UTC"
|
|
|
|
|
2021-12-12 11:43:27 +08:00
|
|
|
COPY --from=backend /backend-build/memos /usr/local/memos/
|
|
|
|
|
2023-03-09 08:33:33 +08:00
|
|
|
EXPOSE 5230
|
|
|
|
|
2022-02-05 13:04:06 +08:00
|
|
|
# Directory to store the data, which can be referenced as the mounting point.
|
|
|
|
RUN mkdir -p /var/opt/memos
|
2023-05-23 18:50:17 +08:00
|
|
|
VOLUME /var/opt/memos
|
2021-12-12 11:43:27 +08:00
|
|
|
|
2023-05-24 20:08:47 +08:00
|
|
|
ENV MEMOS_MODE="prod"
|
|
|
|
ENV MEMOS_PORT="5230"
|
|
|
|
|
|
|
|
ENTRYPOINT ["./memos"]
|