Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Paul Lhussiez
committed
Sep 17, 2018
1 parent
09519cd
commit 1ff65f2
Showing
6 changed files
with
95 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ _testmain.go | |
smallblog | ||
pages/ | ||
conf.yml | ||
releases | ||
vendor | ||
releases/ | ||
dist/ | ||
vendor/ | ||
coverage.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: [linux] | ||
goarch: [amd64, arm, arm64, 386] | ||
goarm: [6, 7] | ||
archive: | ||
wrap_in_directory: true | ||
format: tar.gz | ||
replacements: | ||
386: i386 | ||
amd64: x86_64 | ||
files: | ||
- examples/**/* | ||
- templates/**/* | ||
- assets/**/* | ||
- pages/**/* | ||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ .Tag }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Build Step | ||
FROM golang:latest AS build | ||
|
||
# Prerequisites and vendoring | ||
RUN mkdir -p $GOPATH/src/github.com/Depado/smallblog | ||
ADD . $GOPATH/src/github.com/Depado/smallblog | ||
WORKDIR $GOPATH/src/github.com/Depado/smallblog | ||
RUN go get -u github.com/golang/dep/cmd/dep | ||
RUN dep ensure -vendor-only | ||
|
||
# Build | ||
ARG build | ||
ARG version | ||
RUN CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=${version} -X main.Build=${build}" -o /smallblog | ||
|
||
# Final Step | ||
FROM alpine | ||
|
||
# Base packages | ||
RUN apk update | ||
RUN apk upgrade | ||
RUN apk add ca-certificates && update-ca-certificates | ||
RUN apk add --update tzdata | ||
RUN rm -rf /var/cache/apk/* | ||
|
||
# Copy binary from build step | ||
COPY --from=build /smallblog /home/ | ||
|
||
# Define timezone | ||
ENV TZ=Europe/Paris | ||
|
||
# Define the ENTRYPOINT | ||
WORKDIR /home | ||
ENTRYPOINT ./smallblog | ||
|
||
# Document that the service listens on port 8080. | ||
EXPOSE 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,32 @@ | ||
version = 1.0.2 | ||
.PHONY: all clean test docker latest release | ||
|
||
.PHONY: release clean | ||
export CGO_ENABLED=0 | ||
export GOOS=linux | ||
export GOARCH=amd64 | ||
|
||
release: | ||
-mkdir -p releases/smallblog-linux-amd64-${version}/pages | ||
-mkdir -p releases/smallblog-linux-arm-${version}/pages | ||
cp -r assets/ releases/smallblog-linux-amd64-${version} | ||
cp -r assets/ releases/smallblog-linux-arm-${version} | ||
cp -r templates/ releases/smallblog-linux-amd64-${version} | ||
cp -r templates/ releases/smallblog-linux-arm-${version} | ||
cp examples/article.md.example releases/smallblog-linux-amd64-${version}/pages/article.md | ||
cp examples/article.md.example releases/smallblog-linux-arm-${version}/pages/article.md | ||
cp examples/conf.yml.example releases/smallblog-linux-amd64-${version}/conf.yml | ||
cp examples/conf.yml.example releases/smallblog-linux-arm-${version}/conf.yml | ||
go build -o releases/smallblog-linux-amd64-${version}/smallblog | ||
GOARCH=arm go build -o releases/smallblog-linux-arm-${version}/smallblog | ||
cd releases | ||
tar czf smallblog-linux-amd64-${version}.tar.gz smallblog-linux-amd64-${version} | ||
tar czf smallblog-linux-arm-${version}.tar.gz smallblog-linux-arm-${version} | ||
BINARY=smallblog | ||
VERSION=$(shell git describe --abbrev=0 --tags 2> /dev/null || echo "0.1.0") | ||
BUILD=$(shell git rev-parse HEAD 2> /dev/null || echo "undefined") | ||
LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.Build=$(BUILD)" | ||
|
||
all: | ||
go build -o $(BINARY) $(LDFLAGS) | ||
|
||
docker: | ||
docker build \ | ||
-t $(BINARY):latest \ | ||
-t $(BINARY):$(VERSION) \ | ||
--build-arg build=$(BUILD) --build-arg version=$(VERSION) \ | ||
-f Dockerfile --no-cache . | ||
|
||
latest: | ||
docker build \ | ||
-t $(BINARY):latest \ | ||
--build-arg build=$(BUILD) --build-arg version=$(VERSION) \ | ||
-f Dockerfile --no-cache . | ||
|
||
test: | ||
go test ./... | ||
|
||
clean: | ||
-rm -r releases/ | ||
if [ -f $(BINARY) ] ; then rm $(BINARY) ; fi |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.