Skip to content

Commit

Permalink
Merge pull request #94 from ivanilves/refit-docker-build
Browse files Browse the repository at this point in the history
Refit Docker build to match our current demands
  • Loading branch information
vonrabbe authored Nov 4, 2017
2 parents 0ce9142 + b627bc4 commit d2e171b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 31 deletions.
20 changes: 12 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# This file is a template, and might need editing before it works on your project.
FROM golang:1.8-alpine AS builder
# We'll likely need to add SSL root certificates
RUN apk --no-cache add ca-certificates
# Missing part for compiling the application by it self because it requires a sock
#
# NB! This file is a template and might need editing before it works on your project!
#
FROM golang:1.8 AS builder
WORKDIR /go/src/github.com/ivanilves/lstags
COPY . ./
RUN ln -nfs /bin/bash /bin/sh && make assemble
FROM scratch
# Since we started from scratch, we'll copy the SSL root certificates from the builder
# Since we started from scratch, we'll copy following files from the builder:
# * SSL root certificates bundle
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY lstags /usr/local/bin/lstags
ENTRYPOINT [ "/usr/local/bin/lstags" ]
# * compiled lstags binary
COPY --from=builder /go/src/github.com/ivanilves/lstags/lstags /lstags
ENTRYPOINT [ "/lstags" ]
CMD ["--help"]
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ all: prepare dep test lint vet build

offline: unit-test lint vet build

assemble: prepare dep lint vet build

prepare:
go get -u -v \
github.com/golang/dep/cmd/dep \
Expand Down Expand Up @@ -69,10 +71,10 @@ shell-test-push-local:
./lstags localhost:${REGISTRY_PORT}/qa/library/alpine
${MAKE} --no-print-directory stop-local-registry

lint: ERRORS:=$(shell find . -name "*.go" ! -path "./vendor/*" | xargs -i golint {} | tr '`' '|')
lint: ERRORS=$(shell find . -name "*.go" ! -path "./vendor/*" | xargs -i golint {} | tr '`' '|')
lint: fail-on-errors

vet: ERRORS:=$(shell find . -name "*.go" ! -path "./vendor/*" | xargs -i go tool vet {} | tr '`' '|')
vet: ERRORS=$(shell find . -name "*.go" ! -path "./vendor/*" | xargs -i go tool vet {} | tr '`' '|')
vet: fail-on-errors

fail-on-errors:
Expand Down Expand Up @@ -121,6 +123,7 @@ deploy:
GITHUB_TOKEN=${GITHUB_TOKEN} ./scripts/github-create-release.sh ./dist/release
GITHUB_TOKEN=${GITHUB_TOKEN} ./scripts/github-upload-assets.sh ${TAG} ./dist/assets

docker: DOCKER_REPO:=ivanilves/lstags
docker: RELEASE_TAG:=latest
docker:
@docker container run -v $(shell pwd):/go/src/github.com/ivanilves/lstags -w /go/src/github.com/ivanilves/lstags -v /var/run/docker.sock:/var/run/docker.sock golang:1.8 scripts/prepare-docker-build.sh
@docker image build -t ivanilves/lstags .
@docker image build -t ${DOCKER_REPO}:${RELEASE_TAG} .
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ You could use `lstags`, if you ...
* ... compare local images with registry ones (e.g. know, if image tagged "latest" was re-pushed).

... pull Ubuntu 14.04 & 16.04, all the Alpine images and Debian "stretch" to have latest software to play with:
```
```sh
lstags --pull ubuntu~/^1[46]\\.04$/ alpine debian~/stretch/
```
... pull and re-push CoreOS-related images from `quay.io` to your own registry (in case these hipsters will break everything):
```
```sh
lstags -P /quay -r registry.company.io quay.io/coreos/hyperkube quay.io/coreos/flannel
```
**NB!** In case you use private registry with authentication, make sure your Docker client knows how to authenticate against it!
Expand All @@ -59,7 +59,7 @@ You can either:
https://github.com/ivanilves/lstags/releases

## Install: From source
```
```sh
git clone [email protected]:ivanilves/lstags.git
cd lstags
dep ensure
Expand All @@ -68,9 +68,9 @@ go build
```
**NB!** I assume you have current versions of Go & [dep](https://github.com/golang/dep) installed and also have set up [GOPATH](https://github.com/golang/go/wiki/GOPATH) correctly.

## Using it with docker
## Using it with Docker

```sh
```
docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock ivanilves/lstags
Usage:
lstags [OPTIONS] REPO1 REPO2 REPOn...
Expand Down Expand Up @@ -108,17 +108,17 @@ Arguments:

### Analyze an image

```sh
docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock ivanilves/lstags alpine~/^3\\./
```
docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock ivanilves/lstags alpine~/^3\\./
ANALYZE alpine
FETCHED alpine
-
<STATE> <DIGEST> <(local) ID> <Created At> <TAG>
CHANGED sha256:b40e202395eaec699f2d0c5e01e6d6cb8 76da55c8019d 2017-10-25T23:19:51Z alpine:3.6
ABSENT sha256:d95da16498d5d6fb4b907cbe013f95032 n/a 2017-10-25T23:20:18Z alpine:3.1
ABSENT sha256:cb275b62f789b211114f28b391fca3cc2 n/a 2017-10-25T23:20:32Z alpine:3.2
ABSENT sha256:27af7da847283a947c008592f2b2cd6d2 n/a 2017-10-25T23:20:45Z alpine:3.3
CHANGED sha256:246bbbaa81b28837b64cb9dfc574de958 1a19a71e5d38 2017-10-25T23:20:59Z alpine:3.4
CHANGED sha256:aa96c8dc3815c44d4aceaf1ee7903ce58 37c7be7a096b 2017-10-25T23:21:13Z alpine:3.5
<STATE> <DIGEST> <(local) ID> <Created At> <TAG>
CHANGED sha256:b40e202395eaec699f2d0c5e01e6d6cb8 76da55c8019d 2017-10-25T23:19:51Z alpine:3.6
ABSENT sha256:d95da16498d5d6fb4b907cbe013f95032 n/a 2017-10-25T23:20:18Z alpine:3.1
ABSENT sha256:cb275b62f789b211114f28b391fca3cc2 n/a 2017-10-25T23:20:32Z alpine:3.2
ABSENT sha256:27af7da847283a947c008592f2b2cd6d2 n/a 2017-10-25T23:20:45Z alpine:3.3
CHANGED sha256:246bbbaa81b28837b64cb9dfc574de958 1a19a71e5d38 2017-10-25T23:20:59Z alpine:3.4
CHANGED sha256:aa96c8dc3815c44d4aceaf1ee7903ce58 37c7be7a096b 2017-10-25T23:21:13Z alpine:3.5
-
```
5 changes: 0 additions & 5 deletions scripts/prepare-docker-build.sh

This file was deleted.

0 comments on commit d2e171b

Please sign in to comment.