diff --git a/Dockerfile (copy) b/Dockerfile (copy) new file mode 100644 index 000000000..fa47807a8 --- /dev/null +++ b/Dockerfile (copy) @@ -0,0 +1,35 @@ +FROM node:20 as node + +WORKDIR /app +COPY web web + +## remove generated files in case the developer build with npm before +RUN rm -rf web/assets/ts-dist &&\ + rm -rf web/assets/css-dist + +WORKDIR /app/web +RUN npm i --no-dev + +FROM golang:1.21-alpine3.18 as build-env + +RUN mkdir /gostuff +WORKDIR /gostuff +COPY go.mod go.sum ./ + +# Get dependencies - will also be cached if we won't change mod/sum +RUN go mod download + +WORKDIR /go/src/app +COPY . . +COPY --from=node /app/web/assets ./web/assets +COPY --from=node /app/web/node_modules ./web/node_modules + +# bundle version into binary if specified in build-args, dev otherwise. +ARG version=dev +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-w -extldflags '-static' -X main.VersionTag=${version}" -o /go/bin/tumlive cmd/tumlive/tumlive.go + +FROM alpine:3.18 +RUN apk add --no-cache tzdata openssl +WORKDIR /app +COPY --from=build-env /go/bin/tumlive . +CMD ["sh", "-c", "sleep 3 && ./tumlive"]