niki/Dockerfile

37 lines
610 B
Docker
Raw Normal View History

2024-02-18 10:42:21 +00:00
# Build Stage
# First pull Golang image
FROM golang:1.21.3-alpine as builder
# Set environment variable
ENV APP_NAME niki
ENV CMD_PATH main.go
# Add a work directory
WORKDIR /$APP_NAME
## Cache and install dependencies
#COPY go.mod go.sum ./
#RUN go mod download
# Copy app files
COPY . .
# Budild application
2024-03-09 06:59:51 +00:00
RUN CGO_ENABLED=0 go build -mod=mod -v -o $APP_NAME .
2024-02-18 10:42:21 +00:00
# Run Stage
FROM alpine:3.18 as development
# Set environment variable
ENV APP_NAME niki
# Copy only required data into this image
COPY --from=builder /$APP_NAME .
# Expose application port
EXPOSE 1313
# Start app
CMD ./$APP_NAME