# builder
FROM golang:1.21.0-alpine AS builder
ARG VERSION=notset-dockerfile
WORKDIR /usr/src/app
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags=-X=main.version=${VERSION} -v -o /tixe ./tixe.go
# tester
FROM builder AS tester
RUN go test -v ./...
# release
FROM alpine:3.18 AS release
COPY --from=builder /tixe /tixe
ADD ./static /static
EXPOSE 8080
ENTRYPOINT ["/tixe"]