-
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.
Adding the ability to develop Gorson completely in Docker. (#19)
* Adding the ability to develop Gorson completely in Docker. * adding a docker compose file too * updated docker docs to show docker-compose too * fixing typo
- Loading branch information
1 parent
34c9fcd
commit 4ee92dd
Showing
4 changed files
with
91 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM golang:1.13.4-alpine | ||
|
||
# borrowed with gratitude from confd | ||
# https://github.com/kelseyhightower/confd/blob/master/Dockerfile.build.alpine?at=09f6676 | ||
|
||
WORKDIR /app | ||
RUN apk add --no-cache bash gcc git musl-dev | ||
|
||
COPY go.mod /app/go.mod | ||
COPY go.sum /app/go.sum | ||
RUN go mod download |
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,6 @@ | ||
version: '3' | ||
services: | ||
builder: | ||
build: . | ||
volumes: | ||
- .:/app |
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,40 @@ | ||
# Setting up Docker | ||
|
||
This repository has been built with development of `gorson` done entirely in Docker in mind. Below are the steps required to get | ||
this package up and running through Docker. | ||
|
||
## Build Docker image | ||
|
||
```bash | ||
$ docker build -t gorson . | ||
``` | ||
|
||
or | ||
|
||
```bash | ||
$ docker-compose build | ||
``` | ||
|
||
## Run tests on Docker image | ||
|
||
```bash | ||
$ docker run -it -v `pwd`:/app gorson ./scripts/test.sh | ||
``` | ||
|
||
or | ||
|
||
```bash | ||
$ docker-compose run --rm builder ./scripts/test.sh | ||
``` | ||
|
||
## Create releases | ||
|
||
```bash | ||
$ docker run -it -v `pwd`:/app gorson ./scripts/docker-release.sh | ||
``` | ||
|
||
or | ||
|
||
```bash | ||
$ docker-compose run --rm builder ./scripts/docker-release.sh | ||
``` |
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,34 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
# tooling logic borrowed heavily from the talented minds of confd | ||
# https://github.com/kelseyhightower/confd/blob/master/Makefile | ||
|
||
cd "$( dirname "${BASH_SOURCE[0]}" )/.." | ||
|
||
./scripts/clean.sh | ||
mkdir -p bin | ||
|
||
VERSION=`egrep -o '[0-9]+\.[0-9a-z.\-]+' ./internal/gorson/version/version.go` | ||
|
||
# We want to make sure the final builds are formatted and linted properly. | ||
./scripts/format.sh | ||
./scripts/lint.sh | ||
|
||
# for each of our target platforms we use the gorson_builder | ||
# docker container to compile a binary of our application | ||
>&2 echo "compiling binaries for release" | ||
for platform in darwin linux; do \ | ||
binary_name="gorson-${VERSION}-${platform}-amd64" | ||
>&2 echo "compiling $binary_name" | ||
|
||
# * GOOS is the target operating system | ||
# * GOARCH is the target processor architecture | ||
# (we only compile for amd64 systems) | ||
# see https://golang.org/cmd/go/#hdr-Environment_variables | ||
# * CGO_ENABLED controls whether the go compiler allows us to | ||
# import C packages (we don't do this, so we set it to 0 to turn CGO off) | ||
# see https://golang.org/cmd/cgo/ | ||
GOOS=$platform GOARCH=amd64 CGO_ENABLED=0 go build -o bin/$binary_name | ||
done |