Skip to content

Commit 9051727

Browse files
authored
Merge pull request #257 from aaronpowell/dockerfile
Containerising inspector
2 parents 1859e56 + e903662 commit 9051727

File tree

3 files changed

+136
-0
lines changed

3 files changed

+136
-0
lines changed

.dockerignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Version control
2+
.git
3+
.gitignore
4+
5+
# Node.js
6+
node_modules
7+
npm-debug.log
8+
9+
# Build artifacts
10+
client/dist
11+
client/build
12+
server/dist
13+
server/build
14+
15+
# Environment variables
16+
.env
17+
.env.local
18+
.env.development
19+
.env.test
20+
.env.production
21+
22+
# Editor files
23+
.vscode
24+
.idea
25+
26+
# Logs
27+
logs
28+
*.log
29+
30+
# Testing
31+
coverage
32+
33+
# Docker
34+
Dockerfile
35+
.dockerignore

.github/workflows/main.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,52 @@ jobs:
6262
- run: npm run publish-all
6363
env:
6464
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
65+
66+
publish-github-container-registry:
67+
runs-on: ubuntu-latest
68+
if: github.event_name == 'release'
69+
environment: release
70+
needs: build
71+
permissions:
72+
contents: read
73+
packages: write
74+
attestations: write
75+
id-token: write
76+
steps:
77+
- uses: actions/checkout@v4
78+
79+
- name: Log in to the Container registry
80+
uses: docker/login-action@v3
81+
with:
82+
registry: ghcr.io
83+
username: ${{ github.actor }}
84+
password: ${{ secrets.GITHUB_TOKEN }}
85+
86+
- name: Extract metadata (tags, labels) for Docker
87+
id: meta
88+
uses: docker/metadata-action@v5
89+
with:
90+
images: ghcr.io/${{ github.repository }}
91+
92+
- name: Set up QEMU
93+
uses: docker/setup-qemu-action@v3
94+
95+
- name: Set up Docker Buildx
96+
uses: docker/setup-buildx-action@v3
97+
98+
- name: Build and push Docker image
99+
id: push
100+
uses: docker/build-push-action@v6
101+
with:
102+
context: .
103+
push: true
104+
platforms: linux/amd64,linux/arm64
105+
tags: ${{ steps.meta.outputs.tags }}
106+
labels: ${{ steps.meta.outputs.labels }}
107+
108+
- name: Generate artifact attestation
109+
uses: actions/attest-build-provenance@v2
110+
with:
111+
subject-name: ghcr.io/${{ github.repository }}
112+
subject-digest: ${{ steps.push.outputs.digest }}
113+
push-to-registry: true

Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Build stage
2+
FROM node:24-slim AS builder
3+
4+
# Set working directory
5+
WORKDIR /app
6+
7+
# Copy package files for installation
8+
COPY package*.json ./
9+
COPY .npmrc ./
10+
COPY client/package*.json ./client/
11+
COPY server/package*.json ./server/
12+
COPY cli/package*.json ./cli/
13+
14+
# Install dependencies
15+
RUN npm ci --ignore-scripts
16+
17+
# Copy source files
18+
COPY . .
19+
20+
# Build the application
21+
RUN npm run build
22+
23+
# Production stage
24+
FROM node:24-slim
25+
26+
WORKDIR /app
27+
28+
# Copy package files for production
29+
COPY package*.json ./
30+
COPY .npmrc ./
31+
COPY client/package*.json ./client/
32+
COPY server/package*.json ./server/
33+
COPY cli/package*.json ./cli/
34+
35+
# Install only production dependencies
36+
RUN npm ci --omit=dev --ignore-scripts
37+
38+
# Copy built files from builder stage
39+
COPY --from=builder /app/client/dist ./client/dist
40+
COPY --from=builder /app/client/bin ./client/bin
41+
COPY --from=builder /app/server/build ./server/build
42+
COPY --from=builder /app/cli/build ./cli/build
43+
44+
# Set default port values as environment variables
45+
ENV CLIENT_PORT=6274
46+
ENV SERVER_PORT=6277
47+
48+
# Document which ports the application uses internally
49+
EXPOSE ${CLIENT_PORT} ${SERVER_PORT}
50+
51+
# Use ENTRYPOINT with CMD for arguments
52+
ENTRYPOINT ["npm", "start"]

0 commit comments

Comments
 (0)