Skip to content

Commit bce47a4

Browse files
Merge pull request #73 from codecov/feature/add_github_enterprise
starting onprem
2 parents b3606c3 + e020472 commit bce47a4

File tree

13 files changed

+97
-152
lines changed

13 files changed

+97
-152
lines changed

.github/workflows/release.yml

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

Dockerfile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
# syntax=docker/dockerfile:1.3
22
FROM haproxytech/haproxy-alpine:2.9
3-
43
RUN apk update --no-cache && apk upgrade --no-cache openssl && apk add --no-cache gettext
54
RUN mkdir -p /etc/codecov/ssl/certs && chown haproxy:haproxy /etc/codecov/ssl/certs && chown haproxy:haproxy /etc/haproxy
6-
COPY --chmod=755 enterprise.sh /usr/local/bin/enterprise.sh
75
COPY --chown=haproxy:haproxy --chmod=644 config/0-haproxy.conf /etc/haproxy/0-haproxy.conf.template
86
COPY --chown=haproxy:haproxy --chmod=644 config/0-haproxy-no-chroot.conf /etc/haproxy/0-haproxy-no-chroot.conf.template
7+
COPY --chmod=755 entrypoint.sh /usr/local/bin/entrypoint.sh
8+
COPY --chown=haproxy:haproxy --chmod=644 config/3-ssl.conf /etc/haproxy/3-ssl.conf.template
99
COPY --chown=haproxy:haproxy --chmod=644 config/1-backends.conf /etc/haproxy/1-backends.conf.template
1010
COPY --chown=haproxy:haproxy --chmod=644 config/1-minio.conf /etc/haproxy/1-minio.conf.template
1111
COPY --chown=haproxy:haproxy --chmod=644 config/2-http.conf /etc/haproxy/2-http.conf.template
12-
COPY --chown=haproxy:haproxy --chmod=644 config/3-ssl.conf /etc/haproxy/3-ssl.conf.template
13-
14-
COPY --chown=haproxy:haproxy --chmod=644 config/routing.map /etc/haproxy/routing.map
12+
COPY --chown=haproxy:haproxy --chmod=644 config/codecov.map /etc/haproxy/codecov.map
13+
COPY --chown=haproxy:haproxy --chmod=644 config/proxy.map /etc/haproxy/proxy.map
1514
COPY --chown=haproxy:haproxy --chmod=644 config/minio.map /etc/haproxy/minio.map
16-
RUN chown -R haproxy:haproxy /var/lib/haproxy && mkdir -p /run && chown -R haproxy:haproxy /etc/haproxy && chown -R haproxy:haproxy /run
17-
1815
ENV CODECOV_API_HOST=api
1916
ENV CODECOV_API_PORT=8000
2017
ENV CODECOV_API_SCHEME=http
@@ -39,5 +36,7 @@ ENV BUILD_ID $COMMIT_SHA
3936
ENV BUILD_VERSION $VERSION
4037
EXPOSE 8080
4138
EXPOSE 8443
42-
ENTRYPOINT ["/usr/local/bin/enterprise.sh"]
4339

40+
RUN chown -R haproxy:haproxy /var/lib/haproxy && mkdir -p /run && chown -R haproxy:haproxy /etc/haproxy && chown -R haproxy:haproxy /run
41+
42+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

Makefile

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,26 @@ release_version = `cat VERSION`
33
build_date ?= $(shell git show -s --date=iso8601-strict --pretty=format:%cd $$sha)
44
branch = $(shell git branch | grep \* | cut -f2 -d' ')
55
epoch := $(shell date +"%s")
6-
dockerhub_image := codecov/self-hosted-gateway
7-
IMAGE := ${AR_REPO}
8-
export DOCKER_BUILDKIT := 1
6+
AR_REPO ?= codecov/gateway
7+
DOCKERHUB_REPO ?= codecov/self-hosted-gateway
8+
VERSION := ${release_version}-${sha}
9+
export DOCKER_BUILDKIT=1
10+
911

1012
shell:
11-
docker-compose exec gateway sh
13+
GATEWAY_DOCKER_REPO=${AR_REPO} GATEWAY_DOCKER_VERSION=${VERSION} docker-compose exec gateway sh
1214
up:
13-
docker-compose up -d
15+
GATEWAY_DOCKER_REPO=${AR_REPO} GATEWAY_DOCKER_VERSION=${VERSION} docker-compose up -d
1416

1517
refresh:
16-
$(MAKE) build.local
18+
$(MAKE) build
1719
$(MAKE) up
1820

19-
bootstrap:
20-
$(MAKE) gcr.auth
21-
$(MAKE) build.local
22-
23-
gcr.auth:
24-
gcloud auth configure-docker us-docker.pkg.dev
25-
26-
build.local:
27-
docker build . -t ${IMAGE}:${release_version}-latest --build-arg COMMIT_SHA="${sha}" --build-arg VERSION="${release_version}"
28-
docker tag ${IMAGE}:${release_version}-latest ${IMAGE}:latest
29-
docker tag ${IMAGE}:${release_version}-latest ${IMAGE}:latest-stable
21+
build:
22+
make build.self-hosted
3023

3124
build.self-hosted:
32-
docker build . -t ${IMAGE}:${release_version}-${sha} -t ${IMAGE}:${release_version}-latest -t ${dockerhub_image}:rolling \
25+
docker build . -t ${AR_REPO}:${VERSION} -t ${AR_REPO}:${release_version}-latest -t ${DOCKERHUB_REPO}:rolling \
3326
--label "org.label-schema.build-date"="$(build_date)" \
3427
--label "org.label-schema.name"="Self-Hosted Gateway" \
3528
--label "org.label-schema.vendor"="Codecov" \
@@ -38,24 +31,25 @@ build.self-hosted:
3831
--build-arg COMMIT_SHA="${sha}" \
3932
--build-arg VERSION="${release_version}"
4033

34+
4135
tag.self-hosted-rolling:
42-
docker tag ${IMAGE}:${release_version}-${sha} ${dockerhub_image}:rolling
36+
docker tag ${AR_REPO}:${VERSION} ${DOCKERHUB_REPO}:rolling
4337

4438
save.self-hosted:
45-
docker save -o self-hosted.tar ${IMAGE}:${release_version}-${sha}
39+
docker save -o self-hosted.tar ${AR_REPO}:${VERSION}
4640

4741
load.self-hosted:
4842
docker load --input self-hosted.tar
4943

5044
push.self-hosted-rolling:
51-
docker push ${dockerhub_image}:rolling
45+
docker push ${DOCKERHUB_REPO}:rolling
5246

5347
tag.self-hosted-release:
54-
docker tag ${IMAGE}:${release_version}-${sha} ${dockerhub_image}:${release_version}
55-
docker tag ${IMAGE}:${release_version}-${sha} ${dockerhub_image}:latest-stable
56-
docker tag ${IMAGE}:${release_version}-${sha} ${dockerhub_image}:latest-calver
48+
docker tag ${AR_REPO}:${VERSION} ${DOCKERHUB_REPO}:${release_version}
49+
docker tag ${AR_REPO}:${VERSION} ${DOCKERHUB_REPO}:latest-stable
50+
docker tag ${AR_REPO}:${VERSION} ${DOCKERHUB_REPO}:latest-calver
5751

5852
push.self-hosted-release:
59-
docker push ${dockerhub_image}:${release_version}
60-
docker push ${dockerhub_image}:latest-stable
61-
docker push ${dockerhub_image}:latest-calver
53+
docker push ${DOCKERHUB_REPO}:${release_version}
54+
docker push ${DOCKERHUB_REPO}:latest-stable
55+
docker push ${DOCKERHUB_REPO}:latest-calver

README.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ CODECOV_IA_HOST=IA
2020
CODECOV_IA_PORT=8000
2121
CODECOV_IA_SCHEME=http
2222
CODECOV_IA_HOST_HEADER="\$http_host"
23-
CODECOV_FRONTEND_HOST=frontend
24-
CODECOV_FRONTEND_PORT=5000
25-
CODECOV_FRONTEND_SCHEME=http
26-
CODECOV_FRONTEND_HOST_HEADER="\$http_host"
23+
CODECOV_DEFAULT_HOST=frontend
24+
CODECOV_DEFAULT_PORT=5000
25+
CODECOV_DEFAULT_SCHEME=http
26+
CODECOV_DEFAULT_HOST_HEADER="\$http_host"
2727
CODECOV_MINIO_HOST=minio
2828
CODECOV_MINIO_PORT=9000
2929
CODECOV_MINIO_SCHEME=http
@@ -44,14 +44,19 @@ CODECOV_IA_HOST=IA
4444
CODECOV_IA_PORT=8000
4545
CODECOV_IA_SCHEME=http
4646
CODECOV_IA_HOST_HEADER="\$http_host"
47-
CODECOV_FRONTEND_HOST=qa.codecov.dev
48-
CODECOV_FRONTEND_PORT=443
49-
CODECOV_FRONTEND_SCHEME=https
50-
CODECOV_FRONTEND_HOST_HEADER="qa.codecov.dev"
47+
CODECOV_DEFAULT_HOST=qa.codecov.dev
48+
CODECOV_DEFAULT_PORT=443
49+
CODECOV_DEFAULT_SCHEME=https
50+
CODECOV_DEFAULT_HOST_HEADER="qa.codecov.dev"
5151
```
5252

5353
### SSL
54-
This is currently untested. It should be in a working state currently.
54+
1. Mount a valid cert in the container at `/etc/codecov/ssl/certs/cert.crt`
55+
2. Configure the env `CODECOV_GATEWAY_SSL_ENABLED=true`
56+
57+
### Proxy
58+
1. Configure the env `CODECOV_GATEWAY_PROXY_MODE_ENABLED=true`
59+
All requests will now be sent on to the configured CODECOV_DEFAULT host/port.
5560

5661
### Minio
5762
This is mostly intended for when using with docker compose. It makes /export and /archive route to the minio host. To enable minio features use the env var `CODECOV_GATEWAY_MINIO_ENABLED=true`

config/0-haproxy-no-chroot.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,10 @@ frontend stats
5555

5656
backend be_gateway
5757
http-request return status 200 content-type "text/plain" string "${BUILD_VERSION} ${BUILD_ID}" if TRUE
58+
59+
backend be_default
60+
http-request set-header X-Forwarded-Port %[dst_port]
61+
http-request set-header Host ${CODECOV_DEFAULT_HOST_HEADER}
62+
http-request add-header X-Forwarded-Proto https if { ssl_fc }
63+
http-response set-header X-DEFAULT true
64+
server s1 ${CODECOV_DEFAULT_HOST}:${CODECOV_DEFAULT_PORT} check ${CODECOV_DEFAULT_SSL_FLAG}init-addr last,libc,none

config/0-haproxy.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,10 @@ frontend stats
5858

5959
backend be_gateway
6060
http-request return status 200 content-type "text/plain" string "${BUILD_VERSION} ${BUILD_ID}" if TRUE
61+
62+
backend be_default
63+
http-request set-header X-Forwarded-Port %[dst_port]
64+
http-request set-header Host ${CODECOV_DEFAULT_HOST_HEADER}
65+
http-request add-header X-Forwarded-Proto https if { ssl_fc }
66+
http-response set-header X-DEFAULT true
67+
server s1 ${CODECOV_DEFAULT_HOST}:${CODECOV_DEFAULT_PORT} check ${CODECOV_DEFAULT_SSL_FLAG}init-addr last,libc,none

config/1-backends.conf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ backend be_api
55
http-response set-header X-API true
66
server s1 ${CODECOV_API_HOST}:${CODECOV_API_PORT} check ${CODECOV_API_SSL_FLAG}init-addr last,libc,none
77

8-
backend be_frontend
9-
http-request set-header X-Forwarded-Port %[dst_port]
10-
http-request set-header Host ${CODECOV_FRONTEND_HOST_HEADER}
11-
http-request add-header X-Forwarded-Proto https if { ssl_fc }
12-
http-response set-header X-FRONTEND true
13-
server s1 ${CODECOV_FRONTEND_HOST}:${CODECOV_FRONTEND_PORT} check ${CODECOV_FRONTEND_SSL_FLAG}init-addr last,libc,none
14-
158
backend be_ia
169
http-request set-header X-Forwarded-Port %[dst_port]
1710
http-request set-header Host ${CODECOV_IA_HOST_HEADER}

config/2-http.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
frontend http
22
bind :${CODECOV_GATEWAY_HTTP_PORT}
3-
use_backend %[path,map_reg("/etc/haproxy/routing.map")]
4-
default_backend be_frontend
3+
use_backend %[path,map_reg("/etc/haproxy/${CODECOV_GATEWAY_ROUTING_MAP}.map")]
4+
default_backend be_default

config/3-ssl.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ frontend ssl
33
bind :${CODECOV_GATEWAY_HTTPS_PORT} ssl crt /etc/codecov/ssl/certs/cert.crt
44
http-request set-header X-Forwarded-Proto https if { ssl_fc }
55
http-request redirect scheme https unless { ssl_fc }
6-
use_backend %[path,map_reg("/etc/haproxy/routing.map")]
6+
use_backend %[path,map_reg("/etc/haproxy/${CODECOV_GATEWAY_ROUTING_MAP}.map")]
77

8-
default_backend be_frontend
8+
default_backend be_default

config/routing.map renamed to config/codecov.map

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
^/internal(\/.*)?$ be_api
44
^/graphql(\/.*)?$ be_api
55
^/webhooks(\/.*)?$ be_api
6-
^/frontend_health$ be_frontend
6+
^/frontend_health$ be_default
77
^/gateway_health$ be_gateway
88
^/api_health(\/)?$ be_api
99
^/upload/v2(\/)?$ be_api

0 commit comments

Comments
 (0)