Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate images can be pulled before pull operation (#39)
- Loading branch information
Showing
6 changed files
with
64 additions
and
57 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 |
---|---|---|
@@ -1,33 +1,23 @@ | ||
ARG GOLANG_VERSION=1.15.0 | ||
ARG ALPINE_VERSION=3.12.0 | ||
FROM golang:1.15.0 AS builder | ||
|
||
FROM golang:${GOLANG_VERSION} AS builder | ||
WORKDIR /build | ||
COPY . /build | ||
|
||
# Enable static builds | ||
ENV CGO_ENABLED=0 | ||
|
||
RUN go get && \ | ||
go build | ||
|
||
FROM alpine:${ALPINE_VERSION} | ||
WORKDIR /build | ||
COPY . /build | ||
|
||
# OCI annotations (https://github.com/opencontainers/image-spec/blob/master/annotations.md) | ||
LABEL org.opencontainers.image.source="https://github.com/plexsystems/sinker" \ | ||
org.opencontainers.image.title="sinker" \ | ||
org.opencontainers.image.authors="John Reese <john@reese.dev>" \ | ||
org.opencontainers.image.description="Application to sync images from one registry to another" | ||
# SINKER_VERSION is set during the release process | ||
ARG SINKER_VERSION=0.0.0 | ||
RUN go build -ldflags="-X 'github.com/plexsystems/sinker/internal/commands.sinkerVersion=${SINKER_VERSION}'" | ||
|
||
# explicitly set user/group IDs | ||
# RUN set -eux \ | ||
# && addgroup -g 1001 -S sinker \ | ||
# && adduser -S -D -H -u 1001 -s /sbin/nologin -G sinker -g sinker sinker | ||
FROM alpine:3.12.0 | ||
|
||
RUN apk update && apk add --no-cache docker-cli | ||
|
||
COPY --from=builder /build/sinker /usr/bin/ | ||
|
||
# USER sinker | ||
LABEL org.opencontainers.image.source="https://github.com/plexsystems/sinker" | ||
LABEL org.opencontainers.image.title="sinker" | ||
LABEL org.opencontainers.image.authors="John Reese <john@reese.dev>" | ||
LABEL org.opencontainers.image.description="Sync container images from one registry to another" | ||
|
||
ENTRYPOINT ["/usr/bin/sinker"] |
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 |
---|---|---|
@@ -1,23 +1,24 @@ | ||
.PHONY: build | ||
build: | ||
go build | ||
|
||
.PHONY: remove-images | ||
remove-images: | ||
docker rmi `docker images -a -q` | ||
@go build | ||
|
||
.PHONY: test | ||
test: | ||
go test -v ./... -count=1 | ||
@go test -v ./... -count=1 | ||
|
||
.PHONY: acceptance | ||
acceptance: | ||
go build | ||
bats acceptance.bats | ||
acceptance: build | ||
@bats acceptance.bats | ||
|
||
.PHONY: all | ||
all: build test acceptance | ||
|
||
# When using the release target a version must be specified. | ||
# e.g. make release version=v0.1.0 | ||
.PHONY: release | ||
release: | ||
@test $(version) | ||
GOOS=darwin GOARCH=amd64 go build -o sinker-darwin-amd64 -ldflags="-X 'github.com/plexsystems/sinker/internal/commands.sinkerVersion=$(version)'" | ||
GOOS=windows GOARCH=amd64 go build -o sinker-windows-amd64 -ldflags="-X 'github.com/plexsystems/sinker/internal/commands.sinkerVersion=$(version)'" | ||
GOOS=linux GOARCH=amd64 go build -o sinker-linux-amd64 -ldflags="-X 'github.com/plexsystems/sinker/internal/commands.sinkerVersion=$(version)'" | ||
@docker build --build-arg SINKER_VERSION=$(version) -t plexsystems/sinker:$(version) . | ||
@GOOS=darwin GOARCH=amd64 go build -o sinker-darwin-amd64 -ldflags="-X 'github.com/plexsystems/sinker/internal/commands.sinkerVersion=$(version)'" | ||
@GOOS=windows GOARCH=amd64 go build -o sinker-windows-amd64 -ldflags="-X 'github.com/plexsystems/sinker/internal/commands.sinkerVersion=$(version)'" | ||
@GOOS=linux GOARCH=amd64 go build -o sinker-linux-amd64 -ldflags="-X 'github.com/plexsystems/sinker/internal/commands.sinkerVersion=$(version)'" |
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
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
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
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