-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (23 loc) · 753 Bytes
/
Dockerfile
File metadata and controls
36 lines (23 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
FROM golang:alpine as builder
LABEL maintainer="Pedro Lopes <pedroyremolo@gmail.com>"
# Install git.
RUN apk update && apk add --no-cache git
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Test before running
RUN CGO_ENABLED=0 GOOS=linux go test -v ./...
# Build the Go app
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main ./cmd/transfer-server
# Start a new stage from scratch
FROM alpine as runtime
RUN adduser -D worker
USER worker
WORKDIR /home/worker
# Copy the Pre-built binary file from the previous stage. Observe we also copied the .env file
COPY --from=builder --chown=worker:worker /app/main .
# Expose port to the outside world
EXPOSE $APP_PORT
#Command to run the executable
CMD ["./main"]