ci: Move Docker labels declaration inside Dockerfile (#2813)

This commit is contained in:
Geoffrey Gilmore 2019-03-18 17:49:29 -07:00 committed by GitHub
parent d8e57ca3f5
commit 4064c3e87f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 170 additions and 34 deletions

View File

@ -3,7 +3,17 @@
# file, please don't be scared to make it more pleasant / remove hadolint
# ignores.
FROM sourcegraph/alpine:3.9@sha256:987f878657f0dd9734a597c9b5fe6ecd0bda633f6ea556103b9449838b1ed834
FROM sourcegraph/alpine:3.9@sha256:e9264d4748e16de961a2b973cc12259dee1d33473633beccb1dfb8a0e62c6459
ARG COMMIT_SHA="unknown"
ARG DATE="unknown"
ARG VERSION="unknown"
LABEL org.opencontainers.image.revision=${COMMIT_SHA}
LABEL org.opencontainers.image.created=${DATE}
LABEL org.opencontainers.image.version=${VERSION}
LABEL com.sourcegraph.github.url=https://github.com/sourcegraph/sourcegraph/commit/${COMMIT_SHA}
ENV CONFIGURATION_MODE=server PGDATABASE=sg PGHOST=pgsql PGPORT=5432 PGSSLMODE=disable PGUSER=sg PUBLIC_REPO_REDIRECTS=true CACHE_DIR=/mnt/cache/frontend
USER sourcegraph
CMD ["serve"]

View File

@ -22,4 +22,7 @@ for pkg in github.com/sourcegraph/sourcegraph/cmd/frontend; do
done
echo "--- docker build $IMAGE"
docker build -f cmd/frontend/Dockerfile -t $IMAGE $OUTPUT --label "org.opencontainers.image.revision=$COMMIT_SHA" --label="org.opencontainers.image.created=$DATE" --label "org.opencontainers.image.version=$VERSION"
docker build -f cmd/frontend/Dockerfile -t $IMAGE $OUTPUT \
--build-arg COMMIT_SHA \
--build-arg DATE \
--build-arg VERSION

View File

@ -3,7 +3,17 @@
# file, please don't be scared to make it more pleasant / remove hadolint
# ignores.
FROM sourcegraph/alpine:3.9@sha256:987f878657f0dd9734a597c9b5fe6ecd0bda633f6ea556103b9449838b1ed834
FROM sourcegraph/alpine:3.9@sha256:e9264d4748e16de961a2b973cc12259dee1d33473633beccb1dfb8a0e62c6459
ARG COMMIT_SHA="unknown"
ARG DATE="unknown"
ARG VERSION="unknown"
LABEL org.opencontainers.image.revision=${COMMIT_SHA}
LABEL org.opencontainers.image.created=${DATE}
LABEL org.opencontainers.image.version=${VERSION}
LABEL com.sourcegraph.github.url=https://github.com/sourcegraph/sourcegraph/commit/${COMMIT_SHA}
ENV LOG_REQUEST=true
USER sourcegraph
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/github-proxy"]

View File

@ -20,4 +20,7 @@ for pkg in github.com/sourcegraph/sourcegraph/cmd/github-proxy; do
go build -ldflags "-X github.com/sourcegraph/sourcegraph/pkg/version.version=$VERSION" -buildmode exe -tags dist -o $OUTPUT/$(basename $pkg) $pkg
done
docker build -f cmd/github-proxy/Dockerfile -t $IMAGE $OUTPUT --label "org.opencontainers.image.revision=$COMMIT_SHA" --label="org.opencontainers.image.created=$DATE" --label "org.opencontainers.image.version=$VERSION"
docker build -f cmd/github-proxy/Dockerfile -t $IMAGE $OUTPUT \
--build-arg COMMIT_SHA \
--build-arg DATE \
--build-arg VERSION

View File

@ -3,7 +3,17 @@
# file, please don't be scared to make it more pleasant / remove hadolint
# ignores.
FROM sourcegraph/alpine:3.9@sha256:987f878657f0dd9734a597c9b5fe6ecd0bda633f6ea556103b9449838b1ed834
FROM sourcegraph/alpine:3.9@sha256:e9264d4748e16de961a2b973cc12259dee1d33473633beccb1dfb8a0e62c6459
ARG COMMIT_SHA="unknown"
ARG DATE="unknown"
ARG VERSION="unknown"
LABEL org.opencontainers.image.revision=${COMMIT_SHA}
LABEL org.opencontainers.image.created=${DATE}
LABEL org.opencontainers.image.version=${VERSION}
LABEL com.sourcegraph.github.url=https://github.com/sourcegraph/sourcegraph/commit/${COMMIT_SHA}
RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories && \
echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
# hadolint ignore=DL3018

View File

@ -20,4 +20,7 @@ for pkg in github.com/sourcegraph/sourcegraph/cmd/gitserver; do
go build -ldflags "-X github.com/sourcegraph/sourcegraph/pkg/version.version=$VERSION" -buildmode exe -tags dist -o $OUTPUT/$(basename $pkg) $pkg
done
docker build -f cmd/gitserver/Dockerfile -t $IMAGE $OUTPUT --label "org.opencontainers.image.revision=$COMMIT_SHA" --label="org.opencontainers.image.created=$DATE" --label "org.opencontainers.image.version=$VERSION"
docker build -f cmd/gitserver/Dockerfile -t $IMAGE $OUTPUT \
--build-arg COMMIT_SHA \
--build-arg DATE \
--build-arg VERSION

View File

@ -3,6 +3,16 @@
# file, please don't be scared to make it more pleasant / remove hadolint
# ignores.
FROM sourcegraph/alpine:3.9@sha256:987f878657f0dd9734a597c9b5fe6ecd0bda633f6ea556103b9449838b1ed834
FROM sourcegraph/alpine:3.9@sha256:e9264d4748e16de961a2b973cc12259dee1d33473633beccb1dfb8a0e62c6459
ARG COMMIT_SHA="unknown"
ARG DATE="unknown"
ARG VERSION="unknown"
LABEL org.opencontainers.image.revision=${COMMIT_SHA}
LABEL org.opencontainers.image.created=${DATE}
LABEL org.opencontainers.image.version=${VERSION}
LABEL com.sourcegraph.github.url=https://github.com/sourcegraph/sourcegraph/commit/${COMMIT_SHA}
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/loadtest"]
COPY loadtest /usr/local/bin/

View File

@ -20,4 +20,7 @@ for pkg in github.com/sourcegraph/sourcegraph/cmd/loadtest; do
go build -ldflags "-X github.com/sourcegraph/sourcegraph/pkg/version.version=$VERSION" -buildmode exe -tags dist -o $OUTPUT/$(basename $pkg) $pkg
done
docker build -f cmd/loadtest/Dockerfile -t $IMAGE $OUTPUT --label "org.opencontainers.image.revision=$COMMIT_SHA" --label="org.opencontainers.image.created=$DATE" --label "org.opencontainers.image.version=$VERSION"
docker build -f cmd/loadtest/Dockerfile -t $IMAGE $OUTPUT \
--build-arg COMMIT_SHA \
--build-arg DATE \
--build-arg VERSION

View File

@ -3,7 +3,17 @@
# file, please don't be scared to make it more pleasant / remove hadolint
# ignores.
FROM sourcegraph/alpine:3.9@sha256:987f878657f0dd9734a597c9b5fe6ecd0bda633f6ea556103b9449838b1ed834
FROM sourcegraph/alpine:3.9@sha256:e9264d4748e16de961a2b973cc12259dee1d33473633beccb1dfb8a0e62c6459
ARG COMMIT_SHA="unknown"
ARG DATE="unknown"
ARG VERSION="unknown"
LABEL org.opencontainers.image.revision=${COMMIT_SHA}
LABEL org.opencontainers.image.created=${DATE}
LABEL org.opencontainers.image.version=${VERSION}
LABEL com.sourcegraph.github.url=https://github.com/sourcegraph/sourcegraph/commit/${COMMIT_SHA}
ENV PGDATABASE=sg PGHOST=pgsql PGPORT=5432 PGSSLMODE=disable PGUSER=sg
USER sourcegraph
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/management-console"]

View File

@ -21,4 +21,7 @@ for pkg in $path_to_package; do
go build -ldflags "-X github.com/sourcegraph/sourcegraph/pkg/version.version=$VERSION" -buildmode exe -tags dist -o $OUTPUT/$(basename $pkg) $pkg
done
docker build -f cmd/management-console/Dockerfile -t $IMAGE $OUTPUT --label "org.opencontainers.image.revision=$COMMIT_SHA" --label="org.opencontainers.image.created=$DATE" --label "org.opencontainers.image.version=$VERSION"
docker build -f cmd/management-console/Dockerfile -t $IMAGE $OUTPUT \
--build-arg COMMIT_SHA \
--build-arg DATE \
--build-arg VERSION

View File

@ -3,7 +3,17 @@
# file, please don't be scared to make it more pleasant / remove hadolint
# ignores.
FROM sourcegraph/alpine:3.9@sha256:987f878657f0dd9734a597c9b5fe6ecd0bda633f6ea556103b9449838b1ed834
FROM sourcegraph/alpine:3.9@sha256:e9264d4748e16de961a2b973cc12259dee1d33473633beccb1dfb8a0e62c6459
ARG COMMIT_SHA="unknown"
ARG DATE="unknown"
ARG VERSION="unknown"
LABEL org.opencontainers.image.revision=${COMMIT_SHA}
LABEL org.opencontainers.image.created=${DATE}
LABEL org.opencontainers.image.version=${VERSION}
LABEL com.sourcegraph.github.url=https://github.com/sourcegraph/sourcegraph/commit/${COMMIT_SHA}
USER sourcegraph
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/query-runner"]
COPY query-runner /usr/local/bin/

View File

@ -20,4 +20,7 @@ for pkg in github.com/sourcegraph/sourcegraph/cmd/query-runner; do
go build -ldflags "-X github.com/sourcegraph/sourcegraph/pkg/version.version=$VERSION" -buildmode exe -tags dist -o $OUTPUT/$(basename $pkg) $pkg
done
docker build -f cmd/query-runner/Dockerfile -t $IMAGE $OUTPUT --label "org.opencontainers.image.revision=$COMMIT_SHA" --label="org.opencontainers.image.created=$DATE" --label "org.opencontainers.image.version=$VERSION"
docker build -f cmd/query-runner/Dockerfile -t $IMAGE $OUTPUT \
--build-arg COMMIT_SHA \
--build-arg DATE \
--build-arg VERSION

View File

@ -3,7 +3,17 @@
# file, please don't be scared to make it more pleasant / remove hadolint
# ignores.
FROM sourcegraph/alpine:3.9@sha256:987f878657f0dd9734a597c9b5fe6ecd0bda633f6ea556103b9449838b1ed834
FROM sourcegraph/alpine:3.9@sha256:e9264d4748e16de961a2b973cc12259dee1d33473633beccb1dfb8a0e62c6459
ARG COMMIT_SHA="unknown"
ARG DATE="unknown"
ARG VERSION="unknown"
LABEL org.opencontainers.image.revision=${COMMIT_SHA}
LABEL org.opencontainers.image.created=${DATE}
LABEL org.opencontainers.image.version=${VERSION}
LABEL com.sourcegraph.github.url=https://github.com/sourcegraph/sourcegraph/commit/${COMMIT_SHA}
USER sourcegraph
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/repo-updater"]
COPY repo-updater /usr/local/bin/

View File

@ -20,4 +20,7 @@ for pkg in github.com/sourcegraph/sourcegraph/cmd/repo-updater; do
go build -ldflags "-X github.com/sourcegraph/sourcegraph/pkg/version.version=$VERSION" -buildmode exe -tags dist -o $OUTPUT/$(basename $pkg) $pkg
done
docker build -f cmd/repo-updater/Dockerfile -t $IMAGE $OUTPUT --label "org.opencontainers.image.revision=$COMMIT_SHA" --label="org.opencontainers.image.created=$DATE" --label "org.opencontainers.image.version=$VERSION"
docker build -f cmd/repo-updater/Dockerfile -t $IMAGE $OUTPUT \
--build-arg COMMIT_SHA \
--build-arg DATE \
--build-arg VERSION

View File

@ -3,7 +3,17 @@
# file, please don't be scared to make it more pleasant / remove hadolint
# ignores.
FROM sourcegraph/alpine:3.9@sha256:987f878657f0dd9734a597c9b5fe6ecd0bda633f6ea556103b9449838b1ed834
FROM sourcegraph/alpine:3.9@sha256:e9264d4748e16de961a2b973cc12259dee1d33473633beccb1dfb8a0e62c6459
ARG COMMIT_SHA="unknown"
ARG DATE="unknown"
ARG VERSION="unknown"
LABEL org.opencontainers.image.revision=${COMMIT_SHA}
LABEL org.opencontainers.image.created=${DATE}
LABEL org.opencontainers.image.version=${VERSION}
LABEL com.sourcegraph.github.url=https://github.com/sourcegraph/sourcegraph/commit/${COMMIT_SHA}
ENV CACHE_DIR=/mnt/cache/searcher
USER sourcegraph
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/searcher"]

View File

@ -20,4 +20,7 @@ for pkg in github.com/sourcegraph/sourcegraph/cmd/searcher; do
go build -ldflags "-X github.com/sourcegraph/sourcegraph/pkg/version.version=$VERSION" -buildmode exe -tags dist -o $OUTPUT/$(basename $pkg) $pkg
done
docker build -f cmd/searcher/Dockerfile -t $IMAGE $OUTPUT --label "org.opencontainers.image.revision=$COMMIT_SHA" --label="org.opencontainers.image.created=$DATE" --label "org.opencontainers.image.version=$VERSION"
docker build -f cmd/searcher/Dockerfile -t $IMAGE $OUTPUT \
--build-arg COMMIT_SHA \
--build-arg DATE \
--build-arg VERSION

View File

@ -1,19 +1,28 @@
FROM alpine:3.9@sha256:644fcb1a676b5165371437feaa922943aaf7afcfa8bfee4472f6860aad1ef2a0 AS ctags
ARG COMMIT_SHA="unknown"
ARG DATE="unknown"
ARG VERSION="unknown"
LABEL org.opencontainers.image.revision=${COMMIT_SHA}
LABEL org.opencontainers.image.created=${DATE}
LABEL org.opencontainers.image.version=${VERSION}
LABEL com.sourcegraph.github.url=https://github.com/sourcegraph/sourcegraph/commit/${COMMIT_SHA}
# hadolint ignore=DL3003,DL3018,DL4006
RUN apk --no-cache add --virtual build-deps curl jansson-dev \
libseccomp-dev linux-headers autoconf pkgconfig make automake \
gcc g++ binutils
libseccomp-dev linux-headers autoconf pkgconfig make automake \
gcc g++ binutils
ENV CTAGS_VERSION=08a69b5a030cf56c079e3006238b992b34c9cc51
# hadolint ignore=DL3003
RUN curl -fsSL -o ctags.tar.gz "https://codeload.github.com/universal-ctags/ctags/tar.gz/$CTAGS_VERSION" && \
tar -C /tmp -xzf ctags.tar.gz && cd /tmp/ctags-$CTAGS_VERSION && \
./autogen.sh && LDFLAGS=-static ./configure --program-prefix=universal- --enable-json --enable-seccomp && \
make -j8 && make install && cd && \
rm -rf /tmp/ctags-$CTAGS_VERSION && \
apk --no-cache --purge del build-deps
tar -C /tmp -xzf ctags.tar.gz && cd /tmp/ctags-$CTAGS_VERSION && \
./autogen.sh && LDFLAGS=-static ./configure --program-prefix=universal- --enable-json --enable-seccomp && \
make -j8 && make install && cd && \
rm -rf /tmp/ctags-$CTAGS_VERSION && \
apk --no-cache --purge del build-deps
# TODO: Make this image use our sourcegraph/alpine:3.9 base image.
FROM alpine:3.9@sha256:644fcb1a676b5165371437feaa922943aaf7afcfa8bfee4472f6860aad1ef2a0
@ -28,13 +37,13 @@ RUN echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repo
# hadolint ignore=DL3018
RUN apk update && apk add --no-cache \
# NOTE that the Postgres version we run is different
# from our *Minimum Supported Version* which alone dictates
# the features we can depend on. See this link for more information:
# https://github.com/sourcegraph/sourcegraph/blob/master/doc/dev/postgresql.md#version-requirements
'bash=4.4.19-r1' 'postgresql-contrib=11.1-r0' 'postgresql=11.1-r0' \
'redis=3.2.12-r0' bind-tools ca-certificates git@edge \
mailcap nginx openssh-client su-exec tini
# NOTE that the Postgres version we run is different
# from our *Minimum Supported Version* which alone dictates
# the features we can depend on. See this link for more information:
# https://github.com/sourcegraph/sourcegraph/blob/master/doc/dev/postgresql.md#version-requirements
'bash=4.4.19-r1' 'postgresql-contrib=11.1-r0' 'postgresql=11.1-r0' \
'redis=3.2.12-r0' bind-tools ca-certificates git@edge \
mailcap nginx openssh-client su-exec tini
# hadolint ignore=DL3022
COPY --from=sourcegraph/syntect_server:056c730@sha256:2f7489ebddfbbe92bef3e72af3840d24f45d387baa0da1edabf06fa732195ae6 /syntect_server /usr/local/bin/

View File

@ -46,4 +46,7 @@ echo "--- build sqlite for symbols"
env CTAGS_D_OUTPUT_PATH="$OUTPUT/.ctags.d" SYMBOLS_EXECUTABLE_OUTPUT_PATH="$bindir/symbols" BUILD_TYPE=dist ./cmd/symbols/build.sh buildSymbolsDockerImageDependencies
echo "--- docker build"
docker build -f cmd/server/Dockerfile -t "$IMAGE" "$OUTPUT" --label "org.opencontainers.image.revision=$COMMIT_SHA" --label="org.opencontainers.image.created=$DATE" --label "org.opencontainers.image.version=$VERSION"
docker build -f cmd/server/Dockerfile -t "$IMAGE" "$OUTPUT" \
--build-arg COMMIT_SHA \
--build-arg DATE \
--build-arg VERSION

View File

@ -172,7 +172,10 @@ function buildSymbolsDockerImage() {
buildSymbolsDockerImageDependencies
echo "Building the $IMAGE Docker image..."
docker build --quiet -f cmd/symbols/Dockerfile -t "$IMAGE" "$symbolsDockerBuildContext" --label "org.opencontainers.image.revision=$COMMIT_SHA" --label="org.opencontainers.image.created=$DATE" --label "org.opencontainers.image.version=$VERSION"
docker build --quiet -f cmd/symbols/Dockerfile -t "$IMAGE" "$symbolsDockerBuildContext" \
--build-arg COMMIT_SHA \
--build-arg DATE \
--build-arg VERSION
echo "Building the $IMAGE Docker image... done"
}

View File

@ -3,6 +3,10 @@
FROM alpine:3.9@sha256:644fcb1a676b5165371437feaa922943aaf7afcfa8bfee4472f6860aad1ef2a0
LABEL org.opencontainers.image.url=https://sourcegraph.com/
LABEL org.opencontainers.image.source=https://github.com/sourcegraph/sourcegraph/
LABEL org.opencontainers.image.documentation=https://docs.sourcegraph.com/
# Add the sourcegraph group, user, and create the home directory.
#
# We use a static GID/UID assignment to ensure files can be chown'd to this

View File

@ -3,7 +3,17 @@
# file, please don't be scared to make it more pleasant / remove hadolint
# ignores.
FROM sourcegraph/alpine:3.9@sha256:987f878657f0dd9734a597c9b5fe6ecd0bda633f6ea556103b9449838b1ed834
FROM sourcegraph/alpine:3.9@sha256:e9264d4748e16de961a2b973cc12259dee1d33473633beccb1dfb8a0e62c6459
ARG COMMIT_SHA="unknown"
ARG DATE="unknown"
ARG VERSION="unknown"
LABEL org.opencontainers.image.revision=${COMMIT_SHA}
LABEL org.opencontainers.image.created=${DATE}
LABEL org.opencontainers.image.version=${VERSION}
LABEL com.sourcegraph.github.url=https://github.com/sourcegraph/sourcegraph/commit/${COMMIT_SHA}
ENV CONFIGURATION_MODE=server PGDATABASE=sg PGHOST=pgsql PGPORT=5432 PGSSLMODE=disable PGUSER=sg PUBLIC_REPO_REDIRECTS=true
USER sourcegraph
CMD ["serve"]

View File

@ -20,4 +20,7 @@ for pkg in github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend; do
go build -ldflags "-X github.com/sourcegraph/sourcegraph/pkg/version.version=$VERSION" -buildmode exe -tags dist -o $OUTPUT/$(basename $pkg) $pkg
done
docker build -f enterprise/cmd/frontend/Dockerfile -t $IMAGE $OUTPUT --label "org.opencontainers.image.revision=$COMMIT_SHA" --label="org.opencontainers.image.created=$DATE" --label "org.opencontainers.image.version=$VERSION"
docker build -f enterprise/cmd/frontend/Dockerfile -t $IMAGE $OUTPUT \
--build-arg COMMIT_SHA \
--build-arg DATE \
--build-arg VERSION