Skip to content

Commit 96e7666

Browse files
committed
feat: enhance Docker setup with versioning and improved build args
1 parent 5849edd commit 96e7666

File tree

3 files changed

+52
-15
lines changed

3 files changed

+52
-15
lines changed

.dockerignore

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,33 @@ npm-debug.log
1010
yarn-debug.log
1111
yarn-error.log
1212

13-
# Project specific
13+
# Source code (not needed since we install from npm)
1414
src
15-
tests
15+
bin
16+
dist
1617
scripts
18+
test
19+
tests
1720
*.ts
21+
*.js
1822
tsconfig.json
19-
.eslintrc
20-
.prettier*
21-
*.test.js
2223
coverage
2324

24-
# Development environment
25+
# Development files
2526
.vscode
2627
.idea
2728
*.swp
2829
*.swo
2930
.DS_Store
31+
.eslintrc*
32+
.prettier*
3033

31-
# Environment
34+
# Environment files
3235
.env
3336
.env.*
3437
!.env.example
38+
39+
# Documentation and config
40+
README.md
41+
PUBLISHING.md
42+
*.md

.github/workflows/docker.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,48 @@ on:
77
workflows: ["Release"]
88
branches: [main]
99
types: [completed]
10+
workflow_dispatch:
11+
inputs:
12+
version:
13+
description: 'Version to build and push (e.g., 1.0.1)'
14+
required: true
15+
type: string
1016

1117
jobs:
1218
docker:
1319
name: Build & Push Docker Image
1420
runs-on: ubuntu-latest
15-
# Only run if the release workflow completed successfully or a release was published
16-
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'release' }}
21+
# Only run if the release workflow completed successfully, a release was published, or manually triggered
22+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'release' || github.event_name == 'workflow_dispatch' }}
1723
steps:
1824
- name: Checkout
1925
uses: actions/checkout@v3
2026
with:
2127
ref: main
2228
fetch-depth: 0
29+
30+
- name: Get package version
31+
id: package-version
32+
run: |
33+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
34+
VERSION="${{ github.event.inputs.version }}"
35+
echo "Using manual version: $VERSION"
36+
else
37+
VERSION=$(node -p "require('./package.json').version")
38+
echo "Using package.json version: $VERSION"
39+
fi
40+
echo "version=$VERSION" >> $GITHUB_OUTPUT
2341
2442
- name: Docker meta
2543
id: meta
2644
uses: docker/metadata-action@v4
2745
with:
2846
images: watercrawl/mcp
2947
tags: |
30-
type=semver,pattern={{version}}
31-
type=semver,pattern={{major}}.{{minor}}
32-
type=semver,pattern={{major}}
48+
type=raw,value=v${{ steps.package-version.outputs.version }}
49+
type=raw,value=latest
3350
type=sha,format=short
34-
latest
51+
type=raw,value={{branch}}-{{sha}}
3552
3653
- name: Set up Docker Buildx
3754
uses: docker/setup-buildx-action@v2
@@ -63,3 +80,5 @@ jobs:
6380
labels: ${{ steps.meta.outputs.labels }}
6481
cache-from: type=gha
6582
cache-to: type=gha,mode=max
83+
build-args: |
84+
VERSION=${{ steps.package-version.outputs.version }}

Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,18 @@ ENV NODE_ENV=production \
66
SSE_PORT=3000 \
77
SSE_ENDPOINT=/sse
88

9-
# Install the published package globally
10-
RUN npm install -g @watercrawl/mcp
9+
# Accept version as build argument
10+
ARG VERSION
11+
ENV VERSION=${VERSION}
12+
13+
# Install the specific version of the published package globally
14+
RUN npm install -g @watercrawl/mcp@${VERSION}
15+
16+
# Create a non-root user
17+
RUN addgroup -g 1001 -S watercrawl && \
18+
adduser -S watercrawl -u 1001
19+
20+
USER watercrawl
1121

1222
# Expose port for SSE server
1323
EXPOSE 3000

0 commit comments

Comments
 (0)