setup docker volumes & versions

This commit is contained in:
Hayden 2022-09-13 21:15:01 -08:00
parent 0b92d57b85
commit 1dc9d6396a
7 changed files with 35 additions and 16 deletions

View file

@ -1,3 +1,4 @@
# Build Nuxt
FROM node:17-alpine as frontend-builder
WORKDIR /app
@ -6,27 +7,31 @@ COPY frontend/package.json frontend/pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --shamefully-hoist
COPY frontend .
RUN pnpm build
RUN ls -la /app/.output/
# Build API
FROM golang:alpine AS builder
RUN apk update
RUN apk upgrade
RUN apk add --update git build-base gcc g++
ARG BUILD_TIME
ARG COMMIT
RUN apk update && \
apk upgrade && \
apk add --update git build-base gcc g++
WORKDIR /go/src/app
COPY ./backend .
RUN go get -d -v ./...
RUN rm -rf ./app/api/public
COPY --from=frontend-builder /app/.output/public ./app/api/public
RUN CGO_ENABLED=1 GOOS=linux go build \
-ldflags "-s -w -X main.Commit=$COMMIT -X main.BuildTime=$BUILD_TIME" \
-o /go/bin/api \
-v ./app/api/*.go \
-ldflags "-s -w -X main.Commit `git rev-parse HEAD` -X main.BuildTime `date -u +%Y-%m-%dT%H:%M:%SZ`"
-v ./app/api/*.go
# Production Stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY ./backend/config.template.yml /app/config.yml
COPY ./backend/config.template.yml /data/config.yml
RUN mkdir /app
COPY --from=builder /go/bin/api /app
RUN chmod +x /app/api
@ -34,4 +39,7 @@ RUN chmod +x /app/api
LABEL Name=homebox Version=0.0.1
EXPOSE 7745
WORKDIR /app
CMD [ "./api" ]
VOLUME [ "/data" ]
ENTRYPOINT [ "/app/api" ]
CMD [ "/data/config.yml" ]