Fix containerfile permission errors

This commit is contained in:
Imbus 2024-03-21 01:24:17 +01:00
parent d4547e997c
commit ed88220a47

View file

@ -13,7 +13,6 @@ FROM docker.io/golang:alpine as go
RUN apk add gcompat RUN apk add gcompat
RUN apk add gcc RUN apk add gcc
RUN apk add musl-dev RUN apk add musl-dev
RUN apk add make
RUN apk add sqlite RUN apk add sqlite
WORKDIR /build WORKDIR /build
ADD backend/go.mod backend/go.sum ./ ADD backend/go.mod backend/go.sum ./
@ -24,9 +23,7 @@ RUN go mod download
# Add the source code # Add the source code
ADD backend . ADD backend .
RUN make migrate RUN go build -o server
# RUN go build -o server
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o ./server ./main.go RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o ./server ./main.go
# Strip the binary for a smaller image # Strip the binary for a smaller image
@ -37,6 +34,7 @@ FROM docker.io/alpine:latest as runner
RUN adduser -D nonroot RUN adduser -D nonroot
RUN addgroup nonroot nonroot RUN addgroup nonroot nonroot
WORKDIR /app WORKDIR /app
RUN chown nonroot:nonroot /app
# Copy the frontend SPA build into public # Copy the frontend SPA build into public
COPY --from=client /build/dist static COPY --from=client /build/dist static
@ -44,9 +42,6 @@ COPY --from=client /build/dist static
# Copy the server binary # Copy the server binary
COPY --from=go /build/server server COPY --from=go /build/server server
# Copy the database
COPY --from=go /build/db.sqlite3 db.sqlite3
# Expose port 8080 # Expose port 8080
EXPOSE 8080 EXPOSE 8080