Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dockerfile build in Makefile #8

Merged
merged 2 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ GO = go
GO_VENDOR = govendor
MKDIR_P = mkdir -p

## For docker
DOCKER_REGISTRY = sdnvortex
IMAGE_TAG = latest
PROJECT = vortex
################################################

.PHONY: all
Expand Down Expand Up @@ -43,7 +47,7 @@ govendor-sync:
src.build:
$(GO) build -v ./src/...
$(MKDIR_P) $(BUILD_FOLDER)/src/cmd/vortex/
$(GO) build -v -o $(BUILD_FOLDER)/src/cmd/vortext/vortex ./src/cmd/vortex/...
$(GO) build -v -o $(BUILD_FOLDER)/src/cmd/vortex/vortex ./src/cmd/vortex/...

.PHONY: src.test
src.test:
Expand All @@ -65,3 +69,7 @@ src.test-coverage:
check-govendor:
$(info check govendor)
@[ "`which $(GO_VENDOR)`" != "" ] || (echo "$(GO_VENDOR) is missing"; false)

## dockerfiles/ ########################################
docker.build:
docker build --tag $(DOCKER_REGISTRY)/$(PROJECT):$(IMAGE_TAG) -f ./dockerfiles/Dockerfile .
12 changes: 4 additions & 8 deletions dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@
FROM golang:1.10-alpine3.7
MAINTAINER David Chang <[email protected]>
# TODO fix path after move out
WORKDIR /go/src/bitbucket.org/linkernetworks/vortex
WORKDIR /go/src/github.com/linkernetworks/vortex

RUN apk add --no-cache protobuf ca-certificates git

# TODO fix path after move out
COPY . /go/src/bitbucket.org/linkernetworks/vortex/src
COPY Makefile /go/src/bitbucket.org/linkernetworks/vortex
COPY . /go/src/github.com/linkernetworks/vortex/src
COPY Makefile /go/src/github.com/linkernetworks/vortex

ENV CGO_ENABLED 0
ENV GOOS linux
ENV TIMEZONE "Asia/Shanghai"
ARG BUILD_MODE=release
ARG BRAND=aurora
RUN apk add --no-cache tzdata && \
cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && \
echo $TIMEZONE > /etc/timezone && \
apk del tzdata
# TODO test go install
RUN go install -tags "${BUILD_MODE} ${BRAND}" ./src/cmd/...
RUN go install ./src/cmd/...

# the final image: vortex
FROM alpine:3.7
Expand All @@ -33,8 +31,6 @@ COPY --from=0 /go/bin /go/bin
# copy the config files from the current working dir
COPY config /vortex/config

ARG BRAND=aurora

# select the config file for deployment
ARG CONFIG=config/k8s.json
COPY ${CONFIG} config/k8s.json
Expand Down