Skip to content

Commit 71376a5

Browse files
committed
ci: add Docker build and GHCR publishing workflow
- Add Dockerfile with Node.js 18 Alpine base image - Add .dockerignore to exclude unnecessary files - Add GitHub Actions workflow for multi-platform Docker builds - Support automatic image tagging on main branch and version tags - Publish images to GitHub Container Registry (ghcr.io)
1 parent ba29297 commit 71376a5

3 files changed

Lines changed: 89 additions & 0 deletions

File tree

.dockerignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
node_modules
2+
npm-debug.log*
3+
.env
4+
.git
5+
.gitignore
6+
README.md
7+
LICENSE
8+
.vscode
9+
.idea
10+
*.md
11+
scripts/
12+
test-assets/

.github/workflows/docker.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build and Push Docker Image to GHCR
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ['v*']
7+
pull_request:
8+
branches: [main]
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
build-and-push:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Set up QEMU
26+
uses: docker/setup-qemu-action@v3
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Log in to Container Registry
32+
uses: docker/login-action@v3
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Extract metadata (tags, labels)
39+
id: meta
40+
uses: docker/metadata-action@v5
41+
with:
42+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
43+
tags: |
44+
type=ref,event=branch
45+
type=semver,pattern={{version}}
46+
type=semver,pattern={{major}}.{{minor}}
47+
type=sha,prefix=
48+
49+
- name: Build and push Docker image
50+
uses: docker/build-push-action@v5
51+
with:
52+
context: .
53+
platforms: linux/amd64,linux/arm64
54+
push: ${{ github.event_name != 'pull_request' }}
55+
tags: ${{ steps.meta.outputs.tags }}
56+
labels: ${{ steps.meta.outputs.labels }}
57+
cache-from: type=gha
58+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM node:18-alpine
2+
3+
LABEL maintainer="bobotechnology"
4+
LABEL description="Fitten Code to OpenAI API Proxy"
5+
6+
WORKDIR /app
7+
8+
COPY package*.json ./
9+
10+
RUN npm install --production
11+
12+
COPY . .
13+
14+
EXPOSE 3000
15+
16+
ENV NODE_ENV=production
17+
ENV PORT=3000
18+
19+
CMD ["node", "index.js"]

0 commit comments

Comments
 (0)