Skip to content

Commit

Permalink
Merge pull request #105 from sarge/add-go-modules-to-docker-files
Browse files Browse the repository at this point in the history
updated docker files to use go modules
  • Loading branch information
delta592 authored Jun 18, 2019
2 parents 6221e72 + 25f290c commit 800d839
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 14 deletions.
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
SOURCE_COMMIT := $(shell git log -1 --pretty=format:"%H")
SOURCE_BRANCH := $(shell git branch | grep \* | cut -d ' ' -f2)
TAG := target/flottbot

.PHONY: all docker

build:
go build -v -a -o flottbot cmd/flottbot/main.go

run: build
./flottbot

docker:
docker build \
--build-arg "SOURCE_BRANCH=$(SOURCE_BRANCH)" \
--build-arg "SOURCE_COMMIT=$(SOURCE_COMMIT)" \
-f "./docker/Dockerfile" \
-t $(TAG) .

docker build \
--build-arg "SOURCE_BRANCH=$(SOURCE_BRANCH)" \
--build-arg "SOURCE_COMMIT=$(SOURCE_COMMIT)" \
-f "./docker/Dockerfile.ruby" \
-t $(TAG):ruby .

docker build \
--build-arg "SOURCE_BRANCH=$(SOURCE_BRANCH)" \
--build-arg "SOURCE_COMMIT=$(SOURCE_COMMIT)" \
-f "./docker/Dockerfile.python" \
-t $(TAG):python .

docker build \
--build-arg "SOURCE_BRANCH=$(SOURCE_BRANCH)" \
--build-arg "SOURCE_COMMIT=$(SOURCE_COMMIT)" \
-f "./docker/Dockerfile.golang" \
-t $(TAG):golang .
8 changes: 4 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
FROM golang:1.11-alpine AS build
FROM golang:1.12-alpine AS build
ARG SOURCE_BRANCH
ARG SOURCE_COMMIT
WORKDIR /go/src/github.com/target/flottbot/
RUN apk add --no-cache git
RUN go get -u github.com/golang/dep/cmd/dep
ENV GO111MODULE=on
COPY / .
RUN dep ensure
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags "-X github.com/target/flottbot/version.Version=${SOURCE_BRANCH} -X github.com/target/flottbot/version.GitHash=${SOURCE_COMMIT}" \
-o flottbot ./cmd/flottbot

FROM alpine:3.8
FROM alpine:3.9
RUN apk --no-cache add ca-certificates && mkdir config
COPY --from=build /go/src/github.com/target/flottbot/flottbot .
EXPOSE 8080 3000 4000
Expand Down
8 changes: 4 additions & 4 deletions docker/Dockerfile.golang
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
FROM golang:1.11-alpine AS build
FROM golang:1.12-alpine AS build
ARG SOURCE_BRANCH
ARG SOURCE_COMMIT
WORKDIR /go/src/github.com/target/flottbot/
RUN apk add --no-cache git
RUN go get -u github.com/golang/dep/cmd/dep
ENV GO111MODULE=on
COPY / .
RUN dep ensure
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags "-X github.com/target/flottbot/version.Version=${SOURCE_BRANCH} -X github.com/target/flottbot/version.GitHash=${SOURCE_COMMIT}" \
-o flottbot ./cmd/flottbot

FROM golang:1.11-alpine
FROM golang:1.12-alpine
RUN apk add --no-cache git && mkdir config
COPY --from=build /go/src/github.com/target/flottbot/flottbot .
EXPOSE 8080 3000 4000
Expand Down
6 changes: 3 additions & 3 deletions docker/Dockerfile.python
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM golang:1.11-alpine AS build
FROM golang:1.12-alpine AS build
ARG SOURCE_BRANCH
ARG SOURCE_COMMIT
WORKDIR /go/src/github.com/target/flottbot/
RUN apk add --no-cache git
RUN go get -u github.com/golang/dep/cmd/dep
ENV GO111MODULE=on
COPY / .
RUN dep ensure
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags "-X github.com/target/flottbot/version.Version=${SOURCE_BRANCH} -X github.com/target/flottbot/version.GitHash=${SOURCE_COMMIT}" \
-o flottbot ./cmd/flottbot
Expand Down
6 changes: 3 additions & 3 deletions docker/Dockerfile.ruby
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM golang:1.11-alpine AS build
FROM golang:1.12-alpine AS build
ARG SOURCE_BRANCH
ARG SOURCE_COMMIT
WORKDIR /go/src/github.com/target/flottbot/
RUN apk add --no-cache git
RUN go get -u github.com/golang/dep/cmd/dep
ENV GO111MODULE=on
COPY / .
RUN dep ensure
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags "-X github.com/target/flottbot/version.Version=${SOURCE_BRANCH} -X github.com/target/flottbot/version.GitHash=${SOURCE_COMMIT}" \
-o flottbot ./cmd/flottbot
Expand Down

0 comments on commit 800d839

Please sign in to comment.