2022-09-14 05:15:01 +00:00
|
|
|
|
2022-09-04 02:42:03 +00:00
|
|
|
# Build Nuxt
|
2023-08-02 14:01:36 +00:00
|
|
|
FROM node:18-alpine as frontend-builder
|
2022-09-04 02:42:03 +00:00
|
|
|
WORKDIR /app
|
|
|
|
RUN npm install -g pnpm
|
|
|
|
COPY frontend/package.json frontend/pnpm-lock.yaml ./
|
|
|
|
RUN pnpm install --frozen-lockfile --shamefully-hoist
|
|
|
|
COPY frontend .
|
|
|
|
RUN pnpm build
|
2022-09-14 05:15:01 +00:00
|
|
|
|
2022-09-04 02:42:03 +00:00
|
|
|
# Build API
|
|
|
|
FROM golang:alpine AS builder
|
2022-09-14 05:15:01 +00:00
|
|
|
ARG BUILD_TIME
|
|
|
|
ARG COMMIT
|
2022-10-14 01:01:01 +00:00
|
|
|
ARG VERSION
|
2022-09-14 05:15:01 +00:00
|
|
|
RUN apk update && \
|
|
|
|
apk upgrade && \
|
|
|
|
apk add --update git build-base gcc g++
|
|
|
|
|
2022-09-04 02:42:03 +00:00
|
|
|
WORKDIR /go/src/app
|
|
|
|
COPY ./backend .
|
|
|
|
RUN go get -d -v ./...
|
2022-09-09 06:05:23 +00:00
|
|
|
RUN rm -rf ./app/api/public
|
2022-10-25 17:17:31 +00:00
|
|
|
COPY --from=frontend-builder /app/.output/public ./app/api/static/public
|
2023-03-23 04:49:49 +00:00
|
|
|
RUN CGO_ENABLED=0 GOOS=linux go build \
|
2022-10-14 01:01:01 +00:00
|
|
|
-ldflags "-s -w -X main.commit=$COMMIT -X main.buildTime=$BUILD_TIME -X main.version=$VERSION" \
|
2022-09-14 04:06:07 +00:00
|
|
|
-o /go/bin/api \
|
2022-09-14 05:15:01 +00:00
|
|
|
-v ./app/api/*.go
|
2022-09-04 02:42:03 +00:00
|
|
|
|
|
|
|
# Production Stage
|
|
|
|
FROM alpine:latest
|
|
|
|
|
2022-09-24 19:33:38 +00:00
|
|
|
ENV HBOX_MODE=production
|
|
|
|
ENV HBOX_STORAGE_DATA=/data/
|
2024-01-04 17:55:26 +00:00
|
|
|
ENV HBOX_STORAGE_SQLITE_URL=/data/homebox.db?_pragma=busy_timeout=2000&_pragma=journal_mode=WAL&_fk=1
|
2022-09-24 19:33:38 +00:00
|
|
|
|
2022-09-04 02:42:03 +00:00
|
|
|
RUN apk --no-cache add ca-certificates
|
2022-09-14 05:15:01 +00:00
|
|
|
RUN mkdir /app
|
2022-09-04 02:42:03 +00:00
|
|
|
COPY --from=builder /go/bin/api /app
|
|
|
|
|
|
|
|
RUN chmod +x /app/api
|
|
|
|
|
|
|
|
LABEL Name=homebox Version=0.0.1
|
2023-02-16 19:36:40 +00:00
|
|
|
LABEL org.opencontainers.image.source="https://github.com/hay-kot/homebox"
|
2022-09-04 02:42:03 +00:00
|
|
|
EXPOSE 7745
|
2024-05-07 18:52:22 +00:00
|
|
|
HEALTHCHECK --interval=30s \
|
|
|
|
--timeout=5s \
|
|
|
|
--start-period=5s \
|
|
|
|
--retries=3 \
|
2024-06-02 20:08:58 +00:00
|
|
|
CMD [ "/usr/bin/wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:7745/api/v1/status" ]
|
2022-09-04 02:42:03 +00:00
|
|
|
WORKDIR /app
|
2022-09-14 05:15:01 +00:00
|
|
|
VOLUME [ "/data" ]
|
|
|
|
|
|
|
|
ENTRYPOINT [ "/app/api" ]
|
2023-02-16 19:36:40 +00:00
|
|
|
CMD [ "/data/config.yml" ]
|