Skip to content

Commit

Permalink
build: added Dockerfile + binaries generator bash script
Browse files Browse the repository at this point in the history
Updates #61
  • Loading branch information
odeke-em committed Oct 8, 2018
1 parent bdb4d3d commit fd2e429
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bin/

# Miscellaneous files
*.sw[op]
*.DS_Store
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM debian:jessie

COPY ./bin/ocagent_linux ocagent

# Expose the OpenCensus interceptor port
EXPOSE 55678/tcp

CMD ["ocagent"]
70 changes: 70 additions & 0 deletions build_binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

# Copyright 2018, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This file is useful to help build binaries or the Docker image
# Usage:
# It provides a couple of commands like:
# a) Building binaries by passing in the GOOS value e.g.
# darwin
# linux
# windows
#
# b) Build all the binaries by passing in: binaries
#
# c) Building the Docker image:
# By passing in argument "docker" and optionally the version to be tagged otherwise it'll be "v0.0.1"


if [[ $# -lt 1 ]]
then
echo -e "Usage: $0 <cmd>\nwhere <cmd> is any of 'docker' 'binaries' or GOOS such as:\ndarwin\nlinux\nwindows"
exit
fi

function build() {
GOOS="$1"
CMD="GOOS=$GOOS go build -o bin/ocagent_$GOOS ./cmd/ocagent"
echo $CMD
eval $CMD
}

function buildAll() {
build darwin
build linux
build windows
}

function dockerBuild() {
build linux
VERSION="$1"
if [[ "$VERSION" == "" ]]
then
VERSION="v0.0.1"
fi

CMD="docker build -t ocagent:$VERSION ."
echo $CMD
eval $CMD
}

case $1 in
"docker")
dockerBuild $2;;
"binaries")
buildAll;;
*)
build "$1"
esac

0 comments on commit fd2e429

Please sign in to comment.