-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improving REST API. Building docker images.
- Loading branch information
Showing
15 changed files
with
444 additions
and
280 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
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 @@ | ||
# Inspired by https://container-solutions.com/faster-builds-in-docker-with-go-1-11/ | ||
# Base build image | ||
FROM golang:1.14.6-alpine3.12 AS build_base | ||
RUN apk add bash make git curl unzip rsync libc6-compat gcc musl-dev | ||
WORKDIR /go/src/github.com/spacemeshos/explorer-backend | ||
|
||
# Force the go compiler to use modules | ||
ENV GO111MODULE=on | ||
ENV GOPROXY=https://proxy.golang.org | ||
|
||
# We want to populate the module cache based on the go.{mod,sum} files. | ||
COPY go.mod . | ||
COPY go.sum . | ||
|
||
# Download dependencies | ||
RUN go mod download | ||
|
||
RUN go get github.com/golang/[email protected] | ||
|
||
# This image builds the explorer-backend | ||
FROM build_base AS server_builder | ||
# Here we copy the rest of the source code | ||
COPY . . | ||
|
||
# And compile the project | ||
RUN make collector | ||
|
||
#In this last stage, we start from a fresh Alpine image, to reduce the image size and not ship the Go compiler in our production artifacts. | ||
FROM alpine AS explorer-collector | ||
|
||
# Finally we copy the statically compiled Go binary. | ||
COPY --from=server_builder /go/src/github.com/spacemeshos/explorer-backend/build/collector /bin/explorer-collector | ||
|
||
ENTRYPOINT ["/bin/explorer-collector"] | ||
|
||
# profiling port | ||
EXPOSE 6060 |
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,42 @@ | ||
VERSION := 0.1.0 | ||
COMMIT = $(shell git rev-parse HEAD) | ||
SHA = $(shell git rev-parse --short HEAD) | ||
CURR_DIR = $(shell pwd) | ||
CURR_DIR_WIN = $(shell cd) | ||
BIN_DIR = $(CURR_DIR)/build | ||
BIN_DIR_WIN = $(CURR_DIR_WIN)/build | ||
export GO111MODULE = on | ||
|
||
BRANCH := $(shell bash -c 'if [ "$$TRAVIS_PULL_REQUEST" == "false" ]; then echo $$TRAVIS_BRANCH; else echo $$TRAVIS_PULL_REQUEST_BRANCH; fi') | ||
|
||
# Set BRANCH when running make manually | ||
ifeq ($(BRANCH),) | ||
BRANCH := $(shell git rev-parse --abbrev-ref HEAD) | ||
endif | ||
|
||
# Setup the -ldflags option to pass vars defined here to app vars | ||
LDFLAGS = -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.branch=${BRANCH}" | ||
|
||
PKGS = $(shell go list ./...) | ||
|
||
PLATFORMS := windows linux darwin | ||
os = $(word 1, $@) | ||
|
||
all: | ||
.PHONY: all | ||
|
||
apiserver: | ||
ifeq ($(OS),Windows_NT) | ||
cd cmd/apiserver ; go build -o $(BIN_DIR_WIN)/apiserver.exe; cd .. | ||
else | ||
cd cmd/apiserver ; go build -o $(BIN_DIR)/apiserver; cd .. | ||
endif | ||
.PHONY: apiserver | ||
|
||
collector: | ||
ifeq ($(OS),Windows_NT) | ||
cd cmd/collector ; go build -o $(BIN_DIR_WIN)/collector.exe; cd .. | ||
else | ||
cd cmd/collector ; go build -o $(BIN_DIR)/collector; cd .. | ||
endif | ||
.PHONY: collector |
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 @@ | ||
merlin@ambrosus.19542 |
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
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
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
Oops, something went wrong.