Skip to content

Commit

Permalink
Merge pull request #14 from concourse/bionic-base-image
Browse files Browse the repository at this point in the history
migrating to ubuntu:bionic and golang-builder
  • Loading branch information
cirocosta authored Mar 26, 2019
2 parents 6b9a078 + 45534f6 commit 9482d4d
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,56 @@ The currently encouraged way to build these images is by using the
* `additional_tags`: *Optional.* The path to a file with whitespace-separated
list of tag values to tag the image with (in addition to the tag configured in
`source`).

## Development

### Prerequisites

* golang is *required* - version 1.11.x or above is required for go mod to work
* docker is *required* - version 17.06.x is tested; earlier versions may also
work.
* go mod is used for dependency management of the golang packages.

### Running the tests

The tests have been embedded with the `Dockerfile`; ensuring that the testing
environment is consistent across any `docker` enabled platform. When the docker
image builds, the test are run inside the docker container, on failure they
will stop the build.

Run the tests with the following commands for both `alpine` and `ubuntu` images:

```sh
docker build -t registry-image-resource -f dockerfiles/alpine/Dockerfile .
docker build -t registry-image-resource -f dockerfiles/ubuntu/Dockerfile .
```

#### Integration tests

The integration requires 2 docker repos, one private and one public. The `docker build`
step requires setting `--build-args` so the integration will run.

Run the tests with the following command:

```sh
docker build . -t registry-image-resource -f dockerfiles/alpine/Dockerfile \
--build-arg DOCKER_PRIVATE_USERNAME="some-username" \
--build-arg DOCKER_PRIVATE_PASSWORD="some-password" \
--build-arg DOCKER_PRIVATE_REPO="some/repo" \
--build-arg DOCKER_PUSH_USERNAME="some-username" \
--build-arg DOCKER_PUSH_PASSWORD="some-password" \
--build-arg DOCKER_PUSH_REPO="some/repo"

docker build . -t registry-image-resource -f dockerfiles/ubuntu/Dockerfile \
--build-arg DOCKER_PRIVATE_USERNAME="some-username" \
--build-arg DOCKER_PRIVATE_PASSWORD="some-password" \
--build-arg DOCKER_PRIVATE_REPO="some/repo" \
--build-arg DOCKER_PUSH_USERNAME="some-username" \
--build-arg DOCKER_PUSH_PASSWORD="some-password" \
--build-arg DOCKER_PUSH_REPO="some/repo"
```

### Contributing

Please make all pull requests to the `master` branch and ensure tests pass
locally.
File renamed without changes.
37 changes: 37 additions & 0 deletions dockerfiles/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM concourse/golang-builder as builder
COPY . /src
WORKDIR /src
ENV CGO_ENABLED 0
RUN go get -d ./...
RUN go build -o /assets/in ./cmd/in
RUN go build -o /assets/out ./cmd/out
RUN go build -o /assets/check ./cmd/check
RUN set -e; for pkg in $(go list ./...); do \
go test -o "/tests/$(basename $pkg).test" -c $pkg; \
done

FROM ubuntu:bionic AS resource
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
tzdata \
ca-certificates \
unzip \
zip \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder assets/ /opt/resource/
RUN chmod +x /opt/resource/*

FROM resource AS tests
COPY --from=builder /tests /tests
ADD . /docker-image-resource
ARG DOCKER_PRIVATE_USERNAME
ARG DOCKER_PRIVATE_PASSWORD
ARG DOCKER_PRIVATE_REPO
ARG DOCKER_PUSH_USERNAME
ARG DOCKER_PUSH_PASSWORD
ARG DOCKER_PUSH_REPO
RUN set -e; for test in /tests/*.test; do \
$test -ginkgo.v; \
done

FROM resource

0 comments on commit 9482d4d

Please sign in to comment.