sourcegraph/cmd/gitserver/Dockerfile
Peter Guy 3d9b72e43c
test the code host connection for Perforce (fixes #43855) (#49069)
# changes

- add p4 to the repo-updater Dockerfile
- bump the version of p4 from 21.2 to 22.2 for all Dockerfiles, and add
hash checking of the download
- enhance the Perforce VCSSyncer so that it captures the output of `p4
depots` and matches it to the given depot, returning errors if the given
depot doen't match any of the depots returned by `p4 depots`
- fill out `ListRepos` in the Perforce Source so that it calls the
Perforce VCSSyncer's IsCloneable, which checks the given depot agains
the depots from the Perforce server

# before and after videos

https://www.loom.com/share/73099aa7f0ec4427a564f07b80a19a46
https://www.loom.com/share/b7d38469baab496ea50ab22bdfa256da

## Test plan
Add or edit a code host with purposefully wrong connection info; either
the host/port, the username, or the password. A warning message will
display (sometimes a timeout message displays instead) in the Manage
Code Host screen, and an error message will display in the list of code
hosts (sometimes have to wait for the next sync before that appears).

Add or modify a depot so that it is invalid. The repository count will
not increase, and an error message will display in the list of code
hosts. There's no error message in the Manage Code Hose screen, which
would be nice - fodder for iteration.
<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

---------

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
Co-authored-by: Indradhanush Gupta <indradhanush.gupta@gmail.com>
2023-03-10 13:16:22 -08:00

71 lines
3.0 KiB
Docker

# This Dockerfile was generated from github.com/sourcegraph/godockerize. It
# was not written by a human, and as such looks janky. As you change this
# file, please don't be scared to make it more pleasant / remove hadolint
# ignores.
# Install p4 CLI (keep this up to date with cmd/server/Dockerfile)
FROM sourcegraph/alpine-3.14:201280_2023-02-23_4.5-1071f8b97a60@sha256:c4970b21169db155c1b497740e622adb23007ac11a87ec571d9ecef8aba0adc5 AS p4cli
# hash provided in http://filehost.perforce.com/perforce/r22.2/bin.linux26x86_64/SHA256SUMS
# if the hash is not provided, calculate it by downloading the file and running `sha256sum` on it in Terminal
RUN echo "8bc10fca1c5a26262b4072deec76150a668581a9749d0504cd443084773d4fd0 /usr/local/bin/p4" >expected_hash && \
wget http://cdist2.perforce.com/perforce/r22.2/bin.linux26x86_64/p4 -O /usr/local/bin/p4 && \
chmod +x /usr/local/bin/p4 && \
sha256sum -c expected_hash
FROM sourcegraph/alpine-3.14:201280_2023-02-23_4.5-1071f8b97a60@sha256:c4970b21169db155c1b497740e622adb23007ac11a87ec571d9ecef8aba0adc5 AS p4-fusion
COPY p4-fusion-install-alpine.sh /p4-fusion-install-alpine.sh
RUN /p4-fusion-install-alpine.sh
FROM sourcegraph/alpine-3.14:201280_2023-02-23_4.5-1071f8b97a60@sha256:c4970b21169db155c1b497740e622adb23007ac11a87ec571d9ecef8aba0adc5 AS coursier
RUN wget -O coursier.gz https://github.com/coursier/coursier/releases/download/v2.1.0-RC4/cs-x86_64-pc-linux-static.gz && \
gzip -d coursier.gz && \
mv coursier /usr/local/bin/coursier && \
chmod +x /usr/local/bin/coursier
FROM sourcegraph/alpine-3.14:201280_2023-02-23_4.5-1071f8b97a60@sha256:c4970b21169db155c1b497740e622adb23007ac11a87ec571d9ecef8aba0adc5
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 apk add --no-cache \
# Minimal version requirement to address vulnerabilities
# https://github.blog/2023-02-14-git-security-vulnerabilities-announced-3/
'git>=2.39.2-r0' --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main \
git-lfs \
git-p4 \
&& apk add --no-cache \
openssh-client \
# We require libstdc++ for p4-fusion
libstdc++ \
python2 \
python3 \
bash
COPY --from=p4cli /usr/local/bin/p4 /usr/local/bin/p4
COPY --from=p4-fusion /usr/local/bin/p4-fusion /usr/local/bin/p4-fusion
COPY --from=coursier /usr/local/bin/coursier /usr/local/bin/coursier
# This is a trick to include libraries required by p4,
# please refer to https://blog.tilander.org/docker-perforce/
# hadolint ignore=DL4006
RUN wget -O - https://github.com/jtilander/p4d/raw/4600d741720f85d77852dcca7c182e96ad613358/lib/lib-x64.tgz | tar zx --directory /
RUN mkdir -p /data/repos && chown -R sourcegraph:sourcegraph /data/repos
USER sourcegraph
WORKDIR /
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/gitserver"]
COPY gitserver /usr/local/bin/