Skip to content

Commit

Permalink
- Enabled versioning cli.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristoffer Ahl committed Jan 9, 2019
1 parent c039b75 commit 9923cf0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ RUN apk update && apk add --no-cache git ca-certificates && update-ca-certificat
COPY . $GOPATH/src/aws-s3/
WORKDIR $GOPATH/src/aws-s3/
RUN go get -d -v
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o /go/bin/aws-s3
ARG CACHE_TAG
ARG SOURCE_COMMIT
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags "-X 'main.version=$CACHE_TAG' -X 'main.commit=$SOURCE_COMMIT'" -o /go/bin/aws-s3

FROM scratch
COPY --from=builder /go/bin/aws-s3 /go/bin/aws-s3
Expand Down
16 changes: 16 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

declare SHA
declare TAG

SHA="$(git rev-parse --short HEAD)"
TAG='latest'

docker build -t "dotnetmentor/aws-s3:${TAG}" . --build-arg SOURCE_COMMIT="${SHA:?}" --build-arg CACHE_TAG="${TAG:?}"

if [[ -f ./.env ]]; then
# shellcheck disable=SC1091
source ./.env
fi

docker run -e AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID:?}" -e AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY:?}" "dotnetmentor/aws-s3:${TAG}" "$@"
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import (
"github.com/mitchellh/cli"
)

var (
version = "dev"
commit = "none"
)

func main() {
os.Exit(run(os.Args[1:]))
}
Expand All @@ -15,7 +20,7 @@ func run(args []string) int {
// Initialize cli
c := &cli.CLI{
Name: "aws-s3",
Version: "1.0.0",
Version: fmt.Sprintf("%s-%s", version, commit),
Commands: map[string]cli.CommandFactory{
"prune": pruneCommandFactory,
},
Expand Down

0 comments on commit 9923cf0

Please sign in to comment.