Skip to content

Commit

Permalink
Deploy staging env (ciiiii#21)
Browse files Browse the repository at this point in the history
* Deploy staging env

* Fix ci

* Fix staging configuration

* Fix production configuration
  • Loading branch information
ciiiii authored Jun 13, 2024
1 parent 7fbc589 commit 00b8c83
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 20 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ jobs:
runs-on: ubuntu-latest
name: Build & Deploy
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "12.x"
- run: npm install
- uses: actions/checkout@v4
- name: Publish
uses: cloudflare/wrangler-action@2.0.0
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
env:
CF_ACCOUNT_ID: ${{secrets.CF_ACCOUNT_ID}}
accountId: ${{secrets.CF_ACCOUNT_ID}}
command: deploy --env production --minify src/index.js
environment: production
23 changes: 23 additions & 0 deletions .github/workflows/stage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Deploy to Cloudflare Workers(Staging)

on:
pull_request:
branches:
- master
paths-ignore:
- '**.md'
repository_dispatch:

jobs:
build-and-deploy:
runs-on: ubuntu-latest
name: Build & Deploy
steps:
- uses: actions/checkout@v4
- name: Publish
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{secrets.CF_ACCOUNT_ID}}
command: deploy --env staging --minify src/index.js
environment: staging
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ addEventListener("fetch", (event) => {
const dockerHub = "https://registry-1.docker.io";

const routes = {
// production
"docker.libcuda.so": dockerHub,
"quay.libcuda.so": "https://quay.io",
"gcr.libcuda.so": "https://gcr.io",
"k8s-gcr.libcuda.so": "https://k8s.gcr.io",
"k8s.libcuda.so": "https://registry.k8s.io",
"ghcr.libcuda.so": "https://ghcr.io",
"cloudsmith.libcuda.so": "https://docker.cloudsmith.io",

// staging
"docker-staging.libcuda.so": dockerHub,
};

function routeByHosts(host) {
Expand Down
39 changes: 28 additions & 11 deletions wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
name = "cloudflare-docker-proxy"
workers_dev = true
main = "src/index.js"
compatibility_date = "2021-12-07"
compatibility_date = "2023-12-01"

[dev]
ip = "0.0.0.0"
port = 8787
local_protocol="http"
upstream_protocol="https"

[vars]
MODE="production"
TARGET_UPSTREAM=""
local_protocol = "http"

[env.dev.vars]
MODE="debug"
TARGET_UPSTREAM="https://registry-1.docker.io"
MODE = "debug"
TARGET_UPSTREAM = "https://registry-1.docker.io"

[env.production]
name = "cloudflare-docker-proxy"
routes = [
{ pattern = "docker.libcuda.so", custom_domain = true },
{ pattern = "quey.libcuda.so", custom_domain = true },
{ pattern = "gcr.libcuda.so", custom_domain = true },
{ pattern = "k8s-gcr.libcuda.so", custom_domain = true },
{ pattern = "k8s.libcuda.so", custom_domain = true },
{ pattern = "ghcr.libcuda.so", custom_domain = true },
{ pattern = "cloudsmith.libcuda.so", custom_domain = true },
]

[env.production.vars]
MODE = "production"
TARGET_UPSTREAM = ""

[env.staging]
name = "cloudflare-docker-proxy-staging"
route = { pattern = "docker-staging.libcuda.so", custom_domain = true }

[env.staging.vars]
MODE = "staging"
TARGET_UPSTREAM = ""

0 comments on commit 00b8c83

Please sign in to comment.