Skip to content

Commit 00b8c83

Browse files
authored
Deploy staging env (ciiiii#21)
* Deploy staging env * Fix ci * Fix staging configuration * Fix production configuration
1 parent 7fbc589 commit 00b8c83

File tree

4 files changed

+60
-20
lines changed

4 files changed

+60
-20
lines changed

.github/workflows/deploy.yaml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,11 @@ jobs:
1313
runs-on: ubuntu-latest
1414
name: Build & Deploy
1515
steps:
16-
- uses: actions/checkout@v2
17-
- name: Use Node.js
18-
uses: actions/setup-node@v1
19-
with:
20-
node-version: "12.x"
21-
- run: npm install
16+
- uses: actions/checkout@v4
2217
- name: Publish
23-
uses: cloudflare/wrangler-action@2.0.0
18+
uses: cloudflare/wrangler-action@v3
2419
with:
2520
apiToken: ${{ secrets.CF_API_TOKEN }}
26-
env:
27-
CF_ACCOUNT_ID: ${{secrets.CF_ACCOUNT_ID}}
21+
accountId: ${{secrets.CF_ACCOUNT_ID}}
22+
command: deploy --env production --minify src/index.js
23+
environment: production

.github/workflows/stage.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Deploy to Cloudflare Workers(Staging)
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
paths-ignore:
8+
- '**.md'
9+
repository_dispatch:
10+
11+
jobs:
12+
build-and-deploy:
13+
runs-on: ubuntu-latest
14+
name: Build & Deploy
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Publish
18+
uses: cloudflare/wrangler-action@v3
19+
with:
20+
apiToken: ${{ secrets.CF_API_TOKEN }}
21+
accountId: ${{secrets.CF_ACCOUNT_ID}}
22+
command: deploy --env staging --minify src/index.js
23+
environment: staging

src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ addEventListener("fetch", (event) => {
66
const dockerHub = "https://registry-1.docker.io";
77

88
const routes = {
9+
// production
910
"docker.libcuda.so": dockerHub,
1011
"quay.libcuda.so": "https://quay.io",
1112
"gcr.libcuda.so": "https://gcr.io",
1213
"k8s-gcr.libcuda.so": "https://k8s.gcr.io",
1314
"k8s.libcuda.so": "https://registry.k8s.io",
1415
"ghcr.libcuda.so": "https://ghcr.io",
1516
"cloudsmith.libcuda.so": "https://docker.cloudsmith.io",
17+
18+
// staging
19+
"docker-staging.libcuda.so": dockerHub,
1620
};
1721

1822
function routeByHosts(host) {

wrangler.toml

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
11
name = "cloudflare-docker-proxy"
2-
workers_dev = true
3-
main = "src/index.js"
4-
compatibility_date = "2021-12-07"
2+
compatibility_date = "2023-12-01"
53

64
[dev]
75
ip = "0.0.0.0"
86
port = 8787
9-
local_protocol="http"
10-
upstream_protocol="https"
11-
12-
[vars]
13-
MODE="production"
14-
TARGET_UPSTREAM=""
7+
local_protocol = "http"
158

169
[env.dev.vars]
17-
MODE="debug"
18-
TARGET_UPSTREAM="https://registry-1.docker.io"
10+
MODE = "debug"
11+
TARGET_UPSTREAM = "https://registry-1.docker.io"
12+
13+
[env.production]
14+
name = "cloudflare-docker-proxy"
15+
routes = [
16+
{ pattern = "docker.libcuda.so", custom_domain = true },
17+
{ pattern = "quey.libcuda.so", custom_domain = true },
18+
{ pattern = "gcr.libcuda.so", custom_domain = true },
19+
{ pattern = "k8s-gcr.libcuda.so", custom_domain = true },
20+
{ pattern = "k8s.libcuda.so", custom_domain = true },
21+
{ pattern = "ghcr.libcuda.so", custom_domain = true },
22+
{ pattern = "cloudsmith.libcuda.so", custom_domain = true },
23+
]
24+
25+
[env.production.vars]
26+
MODE = "production"
27+
TARGET_UPSTREAM = ""
28+
29+
[env.staging]
30+
name = "cloudflare-docker-proxy-staging"
31+
route = { pattern = "docker-staging.libcuda.so", custom_domain = true }
32+
33+
[env.staging.vars]
34+
MODE = "staging"
35+
TARGET_UPSTREAM = ""

0 commit comments

Comments
 (0)