Skip to content

Commit a1971c7

Browse files
authored
feat: Add docker image build (#61)
* add dockerfile and a fallback for argo cdonfiguration through env vars in http mode * fix lint * chore: add Docker setup step with debug and containerd snapshotter features
1 parent 479abda commit a1971c7

File tree

4 files changed

+85
-4
lines changed

4 files changed

+85
-4
lines changed

.github/workflows/docker.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Create and publish a Docker image
2+
3+
on:
4+
push:
5+
6+
env:
7+
REGISTRY: ghcr.io
8+
IMAGE_NAME: ${{ github.repository }}
9+
10+
jobs:
11+
build-and-push-image:
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
contents: read
16+
packages: write
17+
attestations: write
18+
id-token: write
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v5
23+
24+
- name: Set up Docker
25+
uses: docker/setup-docker-action@v4
26+
with:
27+
daemon-config: |
28+
{
29+
"debug": true,
30+
"features": {
31+
"containerd-snapshotter": true
32+
}
33+
}
34+
35+
- name: Log in to the Container registry
36+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
37+
with:
38+
registry: ${{ env.REGISTRY }}
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Extract metadata (tags, labels) for Docker
43+
id: meta
44+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
45+
with:
46+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
47+
48+
- name: Set up QEMU
49+
uses: docker/setup-qemu-action@v3
50+
51+
- name: Build and push Docker image
52+
id: push
53+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
54+
with:
55+
context: .
56+
push: true
57+
platforms: linux/amd64,linux/arm64
58+
tags: ${{ steps.meta.outputs.tags }}
59+
labels: ${{ steps.meta.outputs.labels }}
60+
61+

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM node:20-slim AS base
2+
ENV PNPM_HOME="/pnpm"
3+
ENV PATH="$PNPM_HOME:$PATH"
4+
RUN corepack enable
5+
COPY . /app
6+
WORKDIR /app
7+
8+
FROM base AS prod-deps
9+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
10+
11+
FROM base AS build
12+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
13+
RUN pnpm run build
14+
15+
FROM base
16+
COPY --from=prod-deps /app/node_modules /app/node_modules
17+
COPY --from=build /app/dist /app/dist
18+
EXPOSE 3000
19+
CMD [ "node", "dist/index.js", "http" ]

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242
"lint:fix": "eslint src/**/*.ts --fix",
4343
"build": "tsup",
4444
"build:watch": "tsup --watch",
45-
"generate-types": "dtsgen -c dtsgen.json -o src/types/argocd.d.ts swagger.json",
46-
"prepare": "npm run build"
45+
"generate-types": "dtsgen -c dtsgen.json -o src/types/argocd.d.ts swagger.json"
4746
},
4847
"author": "Argo Proj Contributors.",
4948
"license": "Apache-2.0",

src/server/transport.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ export const connectHttpTransport = (port: number) => {
6262
if (sessionIdFromHeader && httpTransports[sessionIdFromHeader]) {
6363
transport = httpTransports[sessionIdFromHeader];
6464
} else if (!sessionIdFromHeader && isInitializeRequest(req.body)) {
65-
const argocdBaseUrl = (req.headers['x-argocd-base-url'] as string) || '';
66-
const argocdApiToken = (req.headers['x-argocd-api-token'] as string) || '';
65+
const argocdBaseUrl =
66+
(req.headers['x-argocd-base-url'] as string) || process.env.ARGOCD_BASE_URL || '';
67+
const argocdApiToken =
68+
(req.headers['x-argocd-api-token'] as string) || process.env.ARGOCD_API_TOKEN || '';
6769

6870
if (argocdBaseUrl == '' || argocdApiToken == '') {
6971
res

0 commit comments

Comments
 (0)