File tree 3 files changed +16
-8
lines changed
3 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 6
6
env :
7
7
- CGO_ENABLED=0
8
8
ldflags :
9
- - -s -w -X main.build={{ .Version }} -X main.commit={{ .ShortCommit }} -X main.date={{ .Date }}
9
+ - -s -w
10
10
goos :
11
11
- darwin
12
12
- linux
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ WORKDIR /usr/src/app
7
7
COPY . ./
8
8
9
9
RUN go mod download \
10
- && CGO_ENABLED=0 GOOS=linux go build -a -o main cmd/main/main.go
10
+ && CGO_ENABLED=0 GOOS=linux go build -ldflags= "-s -w" - a -o main cmd/main/main.go
11
11
12
12
13
13
# Final Image
@@ -16,9 +16,10 @@ FROM dimaskiddo/alpine:base
16
16
MAINTAINER Dimas Restu Hidayanto <
[email protected] >
17
17
18
18
ARG SERVICE_NAME="codebase-go-rest"
19
- ENV CONFIG_ENV="production"
19
+ ENV PATH="$PATH:/usr/app/${SERVICE_NAME}" \
20
+ CONFIG_ENV="production"
20
21
21
- WORKDIR /usr/app
22
+ WORKDIR /usr/app/${SERVICE_NAME}
22
23
23
24
COPY --from=go-builder /usr/src/app/config/ ./config
24
25
COPY --from=go-builder /usr/src/app/main ./main
@@ -28,5 +29,5 @@ RUN chmod 777 config/stores config/uploads
28
29
EXPOSE 3000
29
30
HEALTHCHECK --interval=5s --timeout=3s CMD ["curl" , "http://127.0.0.1:3000/health" ] || exit 1
30
31
31
- VOLUME ["/usr/src/ app/config/stores" ,"/usr/src /app/config/uploads" ]
32
- CMD ["./ main" ]
32
+ VOLUME ["/usr/app/config/stores" ,"/usr/app/config/uploads" ]
33
+ CMD ["main" ]
Original file line number Diff line number Diff line change
1
+ BUILD_CGO_ENABLED := 0
1
2
SERVICE_NAME := codebase-go-rest
2
3
SERVICE_PORT := 3000
3
4
IMAGE_NAME := codebase-go-rest
@@ -24,12 +25,18 @@ release:
24
25
make vendor
25
26
make clean-dist
26
27
goreleaser --snapshot --skip-publish --rm-dist
27
- echo " Release complete please check dist directory."
28
+ echo " Release ' $( SERVICE_NAME ) ' complete, please check dist directory."
28
29
29
30
publish :
31
+ make vendor
30
32
make clean-dist
31
33
GITHUB_TOKEN=$(GITHUB_TOKEN ) goreleaser --rm-dist
32
- echo " Publish complete please check your repository releases."
34
+ echo " Publish '$( SERVICE_NAME) ' complete, please check your repository releases."
35
+
36
+ build :
37
+ make vendor
38
+ CGO_ENABLED=$(BUILD_CGO_ENABLED ) go build -ldflags=" -s -w" -a -o $(SERVICE_NAME ) cmd/main/main.go
39
+ echo " Build '$( SERVICE_NAME) ' complete."
33
40
34
41
run :
35
42
go run cmd/main/* .go
You can’t perform that action at this time.
0 commit comments