-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
54 lines (37 loc) · 1.64 KB
/
Dockerfile
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Start from the latest alpine based golang base image
FROM golang:alpine as builder
# Build stamp argument
ARG buildstamp
# Git Commit Id
ARG gitCommitId
# Git Primary Branch
ARG gitPrimaryBranch
# Git Repository
ARG gitRepository
# Git username
ARG gitUsername
# Hostname
ARG hostname
# App Version
ARG appVersion
# Add maintainer info
LABEL maintainer="Shubham Sinha <[email protected]>"
# Set the current working directory inside the container
WORKDIR /app
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download all dependencies
RUN go mod download
# Copy the source from the current directory to the working directory inside the container
COPY . .
# Build Moxy
RUN GOOS=linux GOARCH=amd64 go build -ldflags "-X github.com/sinhashubham95/go-actuator/core.BuildStamp=$buildstamp -X github.com/sinhashubham95/go-actuator/core.GitCommitID=$gitCommitId -X github.com/sinhashubham95/go-actuator/core.GitPrimaryBranch=$gitPrimaryBranch -X github.com/sinhashubham95/go-actuator/core.GitURL=https://github.com/$gitRepository -X github.com/sinhashubham95/go-actuator/core.Username=$gitUsername -X github.com/sinhashubham95/go-actuator/core.HostName=$hostname -X github.com/sinhashubham95/go-actuator/core.GitCommitTime=$buildstamp -X github.com/sinhashubham95/go-actuator/core.GitCommitAuthor=$gitUsername"
# Start again from scratch
FROM scratch
# Copy the binary
COPY --from=builder /app/moxy /moxy
# Set the working directory to data so all created files
# can be mapped to physical files on disk
WORKDIR /data
# Run binary
ENTRYPOINT ["../moxy", "--env=dev", "--name=moxy", "--version=$appVersion", "--port=$port", "--persistence-path=persistence.db"]