godash/Dockerfile

58 lines
1.3 KiB
Text
Raw Normal View History

2024-09-30 12:05:12 +02:00
ARG V_GOLANG=1.23
ARG V_NODE=20
ARG V_ALPINE=3
FROM golang:${V_GOLANG}-alpine AS golang
2024-03-12 15:49:08 +01:00
WORKDIR /app
RUN go install github.com/a-h/templ/cmd/templ@latest
COPY ./go.mod .
COPY ./go.sum .
RUN go mod download
COPY . .
RUN templ generate
RUN go build -ldflags="-s -w" -o godash main.go
2024-09-30 12:05:12 +02:00
FROM node:${V_NODE}-alpine AS node
2024-03-12 15:49:08 +01:00
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --network-timeout 30000
COPY assets/css ./assets/css
COPY components ./components
COPY views ./views
COPY tailwind.config.js .
RUN yarn run tw:build
2024-03-13 11:51:52 +01:00
FROM alpine:${V_ALPINE} AS logo
2024-03-12 15:49:08 +01:00
WORKDIR /app
RUN apk add figlet
RUN figlet GoDash > logo.txt
2024-03-13 11:51:52 +01:00
FROM alpine:${V_ALPINE} AS final
2024-09-30 12:05:12 +02:00
RUN apk --no-cache add tzdata ca-certificates dumb-init && \
rm -rf /tmp/* /var/tmp/* /usr/share/man /var/cache/apk/*
2024-03-12 15:49:08 +01:00
2024-09-30 15:06:16 +02:00
RUN addgroup -g 1000 appgroup && \
adduser -u 1000 -G appgroup -s /bin/bash -D appuser
2024-03-12 15:49:08 +01:00
2024-09-30 12:05:12 +02:00
WORKDIR /app
2024-03-12 15:49:08 +01:00
2024-03-12 16:30:41 +01:00
COPY assets/favicon ./assets/favicon
2024-03-12 15:49:08 +01:00
COPY --from=logo /app/logo.txt .
2024-09-30 12:05:12 +02:00
COPY --from=node /app/assets/css/style.css ./assets/css/style.css
COPY --from=golang /app/views ./views
COPY --from=golang /app/components ./components
COPY --from=golang /app/godash .
2024-03-12 15:49:08 +01:00
ARG APP_VERSION
ENV APP_VERSION=$APP_VERSION
2024-09-30 12:05:12 +02:00
RUN chown -R appuser:appgroup /app
ENTRYPOINT ["dumb-init", "--"]
USER appuser
CMD ["/app/godash"]