Skip to content

Commit

Permalink
Wrap official Grafeas image build (#1)
Browse files Browse the repository at this point in the history
* Update Dockerfile

* Create docker-compose.test.yml

* Create Dockerfile for linting

* Update README.md

* Delete build.sh

* Update config.yaml.toml

* Update entrypoint.sh

* Update docker-compose.test.yml
  • Loading branch information
psprings authored Jul 16, 2019
1 parent 0174d6e commit 6c02408
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 41 deletions.
35 changes: 23 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
FROM golang:1.10.3
COPY . /go/src/github.com/grafeas/grafeas/
WORKDIR /go/src/github.com/grafeas/grafeas/samples/server/go-server/api/server/main
RUN CGO_ENABLED=0 go build -o grafeas-server .
ARG GRAFEAS_VERSION=0.1.0
FROM us.gcr.io/grafeas/grafeas-server:${GRAFEAS_VERSION} as grafeas-official

FROM alpine:latest as confd
ARG CONFD_VERSION=0.15.0
ADD https://github.com/kelseyhightower/confd/releases/download/v${CONFD_VERSION}/confd-${CONFD_VERSION}-linux-amd64 /usr/local/bin/confd
RUN chmod +x /usr/local/bin/confd

FROM alpine:latest
WORKDIR /
ADD https://github.com/kelseyhightower/confd/releases/download/v0.15.0/confd-0.15.0-linux-amd64 /usr/local/bin/confd
COPY build-files /tmp
WORKDIR /grafeas
RUN USER=grafeas && \
UID=1234 && \
GID=5678 && \
addgroup -g "$GID" -S "$USER" && \
adduser --disabled-password \
-u "$UID" -S "$USER" -G "$USER" && \
chown -R grafeas:grafeas /grafeas
COPY --chown=grafeas:grafeas --from=confd /usr/local/bin/confd /usr/local/bin/confd
COPY --chown=grafeas:grafeas --from=grafeas-official /grafeas-server .
COPY --chown=grafeas:grafeas build-files /tmp
RUN chmod +x /usr/local/bin/confd && \
mv /tmp/confd /etc && \
mv /tmp/entrypoint.sh /entrypoint.sh && \
chmod +x /entrypoint.sh
COPY --from=0 /go/src/github.com/grafeas/grafeas/samples/server/go-server/api/server/main/grafeas-server /grafeas-server
mv /tmp/entrypoint.sh /grafeas/entrypoint.sh && \
chmod +x /grafeas/entrypoint.sh
USER grafeas
EXPOSE 8080
ENTRYPOINT ["/entrypoint.sh"]
CMD ["-config", "config.yaml"]
ENTRYPOINT ["/grafeas/entrypoint.sh"]
CMD ["-config", "config.yaml"]
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
# docker-grafeas

## Building the image

To build and run this image locally, run the following command:

```bash
./build.sh
```

## Start a Grafeas server

From locally built image:

```bash
docker run --name grafeas -p 8080:8080 grafeas
```

A prebuilt image can also be used:

```bash
docker run --name grafeas -p 8080:8080 psprings/grafeas
```
Expand Down
4 changes: 2 additions & 2 deletions build-files/confd/conf.d/config.yaml.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[template]
src = "config.yaml.tmpl"
dest = "/config.yaml"
dest = "/grafeas/config.yaml"
keys = [
"/grafeas/api/address",
"/grafeas/api/cafile",
Expand All @@ -14,4 +14,4 @@ keys = [
"/grafeas/postgres/password",
"/grafeas/postgres/sslmode",
"/grafeas/postgres/paginationkey"
]
]
2 changes: 1 addition & 1 deletion build-files/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ fi

/usr/local/bin/confd -onetime -backend "${CONFD_BACKEND}"

exec /grafeas-server "$@"
exec ./grafeas-server "$@"
10 changes: 0 additions & 10 deletions build.sh

This file was deleted.

4 changes: 4 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sut:
dockerfile: test/Dockerfile
build: .
command: hadolint --ignore DL3007 - Dockerfile
3 changes: 3 additions & 0 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ARG HADOLINT_VERSION=latest
FROM hadolint/hadolint:${HADOLINT_VERSION}
COPY Dockerfile .

0 comments on commit 6c02408

Please sign in to comment.