Skip to content

Commit 220d850

Browse files
committed
Slight revamp
1 parent 6f2647f commit 220d850

17 files changed

+88
-244
lines changed

.github/workflows/release.yml

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

Dockerfile

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
# syntax=docker/dockerfile:1.3
2-
ARG BUILD_ENV=self-hosted
3-
FROM haproxytech/haproxy-alpine:2.9 as base
2+
FROM haproxytech/haproxy-alpine:2.9
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
65
COPY --chown=haproxy:haproxy --chmod=644 config/0-haproxy.conf /etc/haproxy/0-haproxy.conf.template
76
COPY --chown=haproxy:haproxy --chmod=644 config/0-haproxy-no-chroot.conf /etc/haproxy/0-haproxy-no-chroot.conf.template
8-
9-
FROM base as self-hosted
10-
COPY --chmod=755 enterprise.sh /usr/local/bin/enterprise.sh
7+
COPY --chmod=755 entrypoint.sh /usr/local/bin/entrypoint.sh
118
COPY --chown=haproxy:haproxy --chmod=644 config/3-ssl.conf /etc/haproxy/3-ssl.conf.template
129
COPY --chown=haproxy:haproxy --chmod=644 config/1-backends.conf /etc/haproxy/1-backends.conf.template
1310
COPY --chown=haproxy:haproxy --chmod=644 config/1-minio.conf /etc/haproxy/1-minio.conf.template
1411
COPY --chown=haproxy:haproxy --chmod=644 config/2-http.conf /etc/haproxy/2-http.conf.template
15-
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
1614
COPY --chown=haproxy:haproxy --chmod=644 config/minio.map /etc/haproxy/minio.map
1715
ENV CODECOV_API_HOST=api
1816
ENV CODECOV_API_PORT=8000
@@ -38,35 +36,7 @@ ENV BUILD_ID $COMMIT_SHA
3836
ENV BUILD_VERSION $VERSION
3937
EXPOSE 8080
4038
EXPOSE 8443
41-
ENTRYPOINT ["/usr/local/bin/enterprise.sh"]
42-
43-
FROM base as onprem
44-
COPY --chmod=755 onprem.sh /usr/local/bin/onprem.sh
45-
COPY --chown=haproxy:haproxy --chmod=644 config/onprem.conf /etc/haproxy/onprem.conf.template
46-
COPY --chown=haproxy:haproxy --chmod=644 config/onprem-ssl.conf /etc/haproxy/onprem-ssl.conf.template
47-
COPY --chown=haproxy:haproxy --chmod=644 config/onprem-http.conf /etc/haproxy/onprem-http.conf.template
48-
COPY --chown=haproxy:haproxy --chmod=644 config/onprem.map /etc/haproxy/routing.map
49-
ENV CODECOV_ONPREM_HOST_HEADER="%[req.hdr(Host)]"
50-
ENV CODECOV_ONPREM_HOST=onprem_host
51-
ENV CODECOV_ONPREM_PORT=onprem_port
52-
ENV CODECOV_GATEWAY_HTTP_PORT=8080
53-
ENV CODECOV_GATEWAY_HTTPS_PORT=8443
54-
ARG COMMIT_SHA
55-
ARG VERSION
56-
ENV BUILD_ID $COMMIT_SHA
57-
ENV BUILD_VERSION $VERSION
58-
EXPOSE 8080
59-
EXPOSE 8443
60-
ENTRYPOINT ["/usr/local/bin/onprem.sh"]
61-
6239

63-
FROM $BUILD_ENV
6440
RUN chown -R haproxy:haproxy /var/lib/haproxy && mkdir -p /run && chown -R haproxy:haproxy /etc/haproxy && chown -R haproxy:haproxy /run
6541

66-
67-
68-
69-
70-
71-
72-
42+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

Makefile

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,71 +3,53 @@ 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" \
3629
--label "org.label-schema.version"="${release_version}-${sha}" \
3730
--label "org.vcs-branch"="$(branch)" \
3831
--build-arg COMMIT_SHA="${sha}" \
39-
--build-arg VERSION="${release_version}" \
40-
--build-arg BUILD_ENV=self-hosted
32+
--build-arg VERSION="${release_version}"
4133

42-
build.onprem:
43-
docker build . -t ${IMAGE}:onprem-${release_version}-${sha} -t ${IMAGE}:onprem-${release_version}-latest -t ${dockerhub_image}:onprem-rolling \
44-
--label "org.label-schema.build-date"="$(build_date)" \
45-
--label "org.label-schema.name"="Self-Hosted Gateway" \
46-
--label "org.label-schema.vendor"="Codecov" \
47-
--label "org.label-schema.vendor"="onprem" \
48-
--label "org.label-schema.version"="${release_version}-${sha}" \
49-
--label "org.vcs-branch"="$(branch)" \
50-
--build-arg COMMIT_SHA="${sha}" \
51-
--build-arg BUILD_ENV=onprem
5234

5335
tag.self-hosted-rolling:
54-
docker tag ${IMAGE}:${release_version}-${sha} ${dockerhub_image}:rolling
36+
docker tag ${AR_REPO}:${VERSION} ${DOCKERHUB_REPO}:rolling
5537

5638
save.self-hosted:
57-
docker save -o self-hosted.tar ${IMAGE}:${release_version}-${sha}
39+
docker save -o self-hosted.tar ${AR_REPO}:${VERSION}
5840

5941
load.self-hosted:
6042
docker load --input self-hosted.tar
6143

6244
push.self-hosted-rolling:
63-
docker push ${dockerhub_image}:rolling
45+
docker push ${DOCKERHUB_REPO}:rolling
6446

6547
tag.self-hosted-release:
66-
docker tag ${IMAGE}:${release_version}-${sha} ${dockerhub_image}:${release_version}
67-
docker tag ${IMAGE}:${release_version}-${sha} ${dockerhub_image}:latest-stable
68-
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
6951

7052
push.self-hosted-release:
71-
docker push ${dockerhub_image}:${release_version}
72-
docker push ${dockerhub_image}:latest-stable
73-
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.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

config/onprem-http.conf

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

0 commit comments

Comments
 (0)