-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Karakoc
committed
Nov 29, 2024
1 parent
6d897bf
commit dc60bcc
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] |