Skip to content

Commit 6c02408

Browse files
authored
Wrap official Grafeas image build (#1)
* 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
1 parent 0174d6e commit 6c02408

File tree

7 files changed

+33
-41
lines changed

7 files changed

+33
-41
lines changed

Dockerfile

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
FROM golang:1.10.3
2-
COPY . /go/src/github.com/grafeas/grafeas/
3-
WORKDIR /go/src/github.com/grafeas/grafeas/samples/server/go-server/api/server/main
4-
RUN CGO_ENABLED=0 go build -o grafeas-server .
1+
ARG GRAFEAS_VERSION=0.1.0
2+
FROM us.gcr.io/grafeas/grafeas-server:${GRAFEAS_VERSION} as grafeas-official
3+
4+
FROM alpine:latest as confd
5+
ARG CONFD_VERSION=0.15.0
6+
ADD https://github.com/kelseyhightower/confd/releases/download/v${CONFD_VERSION}/confd-${CONFD_VERSION}-linux-amd64 /usr/local/bin/confd
7+
RUN chmod +x /usr/local/bin/confd
58

69
FROM alpine:latest
7-
WORKDIR /
8-
ADD https://github.com/kelseyhightower/confd/releases/download/v0.15.0/confd-0.15.0-linux-amd64 /usr/local/bin/confd
9-
COPY build-files /tmp
10+
WORKDIR /grafeas
11+
RUN USER=grafeas && \
12+
UID=1234 && \
13+
GID=5678 && \
14+
addgroup -g "$GID" -S "$USER" && \
15+
adduser --disabled-password \
16+
-u "$UID" -S "$USER" -G "$USER" && \
17+
chown -R grafeas:grafeas /grafeas
18+
COPY --chown=grafeas:grafeas --from=confd /usr/local/bin/confd /usr/local/bin/confd
19+
COPY --chown=grafeas:grafeas --from=grafeas-official /grafeas-server .
20+
COPY --chown=grafeas:grafeas build-files /tmp
1021
RUN chmod +x /usr/local/bin/confd && \
1122
mv /tmp/confd /etc && \
12-
mv /tmp/entrypoint.sh /entrypoint.sh && \
13-
chmod +x /entrypoint.sh
14-
COPY --from=0 /go/src/github.com/grafeas/grafeas/samples/server/go-server/api/server/main/grafeas-server /grafeas-server
23+
mv /tmp/entrypoint.sh /grafeas/entrypoint.sh && \
24+
chmod +x /grafeas/entrypoint.sh
25+
USER grafeas
1526
EXPOSE 8080
16-
ENTRYPOINT ["/entrypoint.sh"]
17-
CMD ["-config", "config.yaml"]
27+
ENTRYPOINT ["/grafeas/entrypoint.sh"]
28+
CMD ["-config", "config.yaml"]

README.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
11
# docker-grafeas
22

3-
## Building the image
4-
5-
To build and run this image locally, run the following command:
6-
7-
```bash
8-
./build.sh
9-
```
10-
113
## Start a Grafeas server
124

13-
From locally built image:
14-
15-
```bash
16-
docker run --name grafeas -p 8080:8080 grafeas
17-
```
18-
19-
A prebuilt image can also be used:
20-
215
```bash
226
docker run --name grafeas -p 8080:8080 psprings/grafeas
237
```

build-files/confd/conf.d/config.yaml.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[template]
22
src = "config.yaml.tmpl"
3-
dest = "/config.yaml"
3+
dest = "/grafeas/config.yaml"
44
keys = [
55
"/grafeas/api/address",
66
"/grafeas/api/cafile",
@@ -14,4 +14,4 @@ keys = [
1414
"/grafeas/postgres/password",
1515
"/grafeas/postgres/sslmode",
1616
"/grafeas/postgres/paginationkey"
17-
]
17+
]

build-files/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ fi
77

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

10-
exec /grafeas-server "$@"
10+
exec ./grafeas-server "$@"

build.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

docker-compose.test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sut:
2+
dockerfile: test/Dockerfile
3+
build: .
4+
command: hadolint --ignore DL3007 - Dockerfile

test/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ARG HADOLINT_VERSION=latest
2+
FROM hadolint/hadolint:${HADOLINT_VERSION}
3+
COPY Dockerfile .

0 commit comments

Comments
 (0)