Skip to content

Commit

Permalink
Merge 4c50d0c into b57a56d
Browse files Browse the repository at this point in the history
  • Loading branch information
darklynx committed Jan 17, 2019
2 parents b57a56d + 4c50d0c commit 5f70da3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
5 changes: 2 additions & 3 deletions docker/multistage/Dockerfile
@@ -1,12 +1,11 @@
# Builds Request Baskets service using multi-stage builds
# Version 1.1
# Version 1.2

# Stage 1. Building service
FROM golang:latest as builder
WORKDIR /go/src/rbaskets
COPY . .
RUN set -e \
&& GIT_VERSION="$(git describe)" \
RUN GIT_VERSION="$(git describe || git symbolic-ref -q --short HEAD)" \
&& GIT_COMMIT="$(git rev-parse HEAD)" \
&& GIT_COMMIT_SHORT="$(git rev-parse --short HEAD)" \
&& set -x \
Expand Down
6 changes: 4 additions & 2 deletions build.sh → scripts/build/build.sh
Expand Up @@ -3,12 +3,14 @@
# exit if any step fails
set -e

# change current dir to the script dir
# change current dir to the script dir and then switch to project root
cd "$(dirname "$0")"
cd ../..

# collect git version information
GIT_VERSION="$(git describe)"
GIT_COMMIT="$(git rev-parse HEAD)"
GIT_COMMIT_SHORT="$(git rev-parse --short HEAD)"

# build service with version information
# build (and install) service with version information from project root for default architecture
go get -ldflags "-X main.GitVersion=${GIT_VERSION} -X main.GitCommit=${GIT_COMMIT} -X main.GitCommitShort=${GIT_COMMIT_SHORT}"
8 changes: 8 additions & 0 deletions scripts/build/build_docker.sh
@@ -0,0 +1,8 @@
#!/bin/sh

# change current dir to the script dir and then switch to project root
cd "$(dirname "$0")"
cd ../..

# build docker container from project root
docker build -t request-baskets .
16 changes: 16 additions & 0 deletions scripts/build/build_linux.sh
@@ -0,0 +1,16 @@
#!/bin/sh

# exit if any step fails
set -e

# change current dir to the script dir and then switch to project root
cd "$(dirname "$0")"
cd ../..

# collect git version information
GIT_VERSION="$(git describe)"
GIT_COMMIT="$(git rev-parse HEAD)"
GIT_COMMIT_SHORT="$(git rev-parse --short HEAD)"

# build service with version information from project root for Linux
env GOOS=linux GOARCH=amd64 go build -ldflags "-X main.GitVersion=${GIT_VERSION} -X main.GitCommit=${GIT_COMMIT} -X main.GitCommitShort=${GIT_COMMIT_SHORT}"

0 comments on commit 5f70da3

Please sign in to comment.