diff --git a/Dockerfile b/Dockerfile index d96f05d..df8da75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,25 @@ # Author:Mateusz Kędziora https://mkedziora.pl FROM golang:1.23.2-alpine AS builder - WORKDIR /app - COPY go.mod go.sum* ./ - RUN go mod download - COPY *.go ./ - RUN CGO_ENABLED=0 GOOS=linux go build -o main . +# Etap minifikacji +FROM node:alpine AS minifier +WORKDIR /app +RUN npm install -g minify +COPY public/ ./public/ +RUN find ./public -name "*.html" -exec minify -o {} {} \; +RUN find ./public/css -name "*.css" -exec minify -o {} {} \; +RUN find ./public/js -name "*.js" -exec minify -o {} {} \; + FROM alpine:latest - RUN apk --no-cache add ca-certificates - WORKDIR /root/ - COPY --from=builder /app/main . - -COPY public/ ./public - +COPY --from=minifier /app/public/ ./public/ EXPOSE 8000 - CMD ["./main"] \ No newline at end of file diff --git a/main.go b/main.go index 8aa7abb..c674cb9 100644 --- a/main.go +++ b/main.go @@ -132,12 +132,20 @@ func main() { http.ServeFile(w, r, "public/app.html") }) - http.HandleFunc("/style_index.css", func(w http.ResponseWriter, r *http.Request) { - http.ServeFile(w, r, "public/style_index.css") + http.HandleFunc("/css/index.css", func(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, "public/css/index.css") }) - http.HandleFunc("/style_app.css", func(w http.ResponseWriter, r *http.Request) { - http.ServeFile(w, r, "public/style_app.css") + http.HandleFunc("/css/app.css", func(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, "public/css/app.css") + }) + + http.HandleFunc("/js/index.js", func(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, "public/js/index.js") + }) + + http.HandleFunc("/js/app.js", func(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, "public/js/app.js") }) go func() { diff --git a/public/app.html b/public/app.html index 1a000a8..8e053a0 100644 --- a/public/app.html +++ b/public/app.html @@ -6,7 +6,7 @@