24 lines
559 B
Docker
24 lines
559 B
Docker
# Build stage
|
|
FROM golang:1.19.4-alpine3.17
|
|
|
|
WORKDIR /app
|
|
|
|
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download && go mod verify
|
|
RUN mkdir /builds
|
|
|
|
COPY . .
|
|
|
|
RUN apk add make
|
|
RUN make install
|
|
RUN make clean
|
|
RUN rm -Rf .git*
|
|
|
|
# Final stage to only keep necessary pre-built binaries and source files
|
|
FROM alpine:3.17.0
|
|
WORKDIR /app
|
|
COPY --from=0 /app /app
|
|
COPY --from=0 /usr/local/bin/gtranslate* /usr/local/bin/
|
|
EXPOSE 5000
|
|
CMD ["gtranslate-server"]
|