Skip to content

Commit

Permalink
Create Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
fossyy authored Sep 15, 2024
1 parent ea6026c commit 0b3dd14
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM node:current-alpine3.20 AS node_builder

WORKDIR /src
COPY /public /src/public
COPY tailwind.config.js .
COPY /view /src/view

RUN npm install -g tailwindcss
RUN npm install -g javascript-obfuscator
RUN npm install -g clean-css-cli
RUN npx tailwindcss -i ./public/input.css -o ./tmp/output.css
RUN javascript-obfuscator ./public/script.js --compact true --self-defending true --output ./public/script_obfuscated.js
RUN cleancss -o ./public/output.css ./tmp/output.css

FROM golang:1.23.1-alpine3.20 AS go_builder

WORKDIR /src
COPY . .
COPY --from=node_builder /src/public /src/public
COPY --from=node_builder /src/public/script_obfuscated.js /src/public/script.js

RUN apk update && apk upgrade && apk add --no-cache ca-certificates tzdata
RUN update-ca-certificates
RUN go install github.com/a-h/templ/cmd/templ@$(go list -m -f '{{ .Version }}' github.com/a-h/templ)
RUN templ generate
RUN go build -o ./tmp/main
RUN rm /src/public/script.js

FROM scratch

WORKDIR /src

COPY --from=go_builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=go_builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=go_builder /src/public /src/public
COPY --from=go_builder /src/tmp/main /src

ENV TZ Asia/Jakarta

ENTRYPOINT ["./main"]

0 comments on commit 0b3dd14

Please sign in to comment.