58 lines
1.6 KiB
Docker
58 lines
1.6 KiB
Docker
FROM node:26-alpine@sha256:aadf416b2cdce311a8811ba3f0608a61b77dbf997500e2eafe781b51f6a0b019 AS frontend
|
|
|
|
WORKDIR /src
|
|
|
|
COPY package.json package-lock.json webpack.config.js ./
|
|
RUN npm ci
|
|
|
|
COPY frontend ./frontend
|
|
RUN npm run build
|
|
|
|
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.10.0 AS xx
|
|
FROM --platform=$BUILDPLATFORM golang:1.27.4-alpine AS build
|
|
ARG TARGETPLATFORM
|
|
ARG GOPROXY
|
|
COPY --from=xx / /
|
|
|
|
WORKDIR /src
|
|
|
|
COPY go.mod ./
|
|
RUN go mod download
|
|
|
|
COPY . .
|
|
COPY --from=frontend /src/static/dist ./static/dist
|
|
|
|
RUN CGO_ENABLED=0 GOOS=linux xx-go build -ldflags "-w -s" -o /out/haste-server .
|
|
|
|
FROM jonasled.dev/infra/images/scratch-rootless:latest@sha256:9e291c85277e40987bdbc84af228b4b40db5c24e1634d047465e2198ed9302e8
|
|
ENV GIN_MODE=release
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
COPY --from=build /out/haste-server ./haste-server
|
|
COPY ./static ./static
|
|
COPY --from=frontend /src/static/dist ./static/dist
|
|
COPY ./about.md ./about.md
|
|
|
|
ENV STORAGE_TYPE=redis \
|
|
STORAGE_HOST=127.0.0.1 \
|
|
STORAGE_PORT=6379 \
|
|
STORAGE_EXPIRE_SECONDS=2592000 \
|
|
STORAGE_DB=2 \
|
|
HOST=0.0.0.0 \
|
|
PORT=7777 \
|
|
KEY_LENGTH=10 \
|
|
MAX_LENGTH=400000 \
|
|
STATIC_MAX_AGE=86400 \
|
|
KEYGENERATOR_TYPE=phonetic \
|
|
RATELIMITS_NORMAL_TOTAL_REQUESTS=500 \
|
|
RATELIMITS_NORMAL_EVERY_MILLISECONDS=60000 \
|
|
# comma separated list for the whitelisted \
|
|
RATELIMITS_WHITELIST=example1.whitelist,example2.whitelist \
|
|
# comma separated list for the blacklisted \
|
|
RATELIMITS_BLACKLIST=example1.blacklist,example2.blacklist \
|
|
DOCUMENTS=about=./about.md
|
|
|
|
EXPOSE ${PORT}
|
|
STOPSIGNAL SIGINT
|
|
CMD ["./haste-server"]
|