chore: add Dockerfile and CI/CD workflow for Docker image builds
Build and Push Docker Image / build (push) Failing after 10s

This commit is contained in:
Daniel Samson committed 2026-10-19 18:02:49 +01:00
1 parent e4866a959a
commit 573c13a467
2 files changed
+72 -30

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
name: Build and Push Docker Image
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
REGISTRY: gitea.samson.media
IMAGE_NAME: samson-media/brave-search-mcp-server
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Gitea Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.GITEA_USERNAME }}
password: ${{ secrets.GITEA_PASSWORD }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
+16 -30
View File
@@ -1,38 +1,24 @@
FROM node:alpine@sha256:5209bcaca9836eb3448b650396213dbe9d9a34d31840c2ae1f206cb2986a8543 AS builder FROM node:22-alpine
RUN apk add --no-cache openssl=3.5.8-r0
WORKDIR /app WORKDIR /app
COPY ./package.json ./package.json # Install build dependencies
COPY ./package-lock.json ./package-lock.json RUN apk add --no-cache git
RUN npm ci --ignore-scripts # Clone and install dependencies
RUN git clone https://github.com/brave/brave-search-mcp-server.git . && \
npm ci --only=production && \
npm run build
COPY ./src ./src # Remove git since we don't need it in runtime
COPY ./tsconfig.json ./tsconfig.json RUN apk del git
RUN npm run build # Expose the MCP server port
EXPOSE 3000
FROM node:alpine@sha256:5209bcaca9836eb3448b650396213dbe9d9a34d31840c2ae1f206cb2986a8543 AS release # Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))"
RUN apk add --no-cache openssl=3.5.8-r0 # Start the MCP server
CMD ["npm", "start"]
WORKDIR /app
COPY --from=builder /app/dist /app/dist
COPY --from=builder /app/package.json /app/package.json
COPY --from=builder /app/package-lock.json /app/package-lock.json
ENV NODE_ENV=production
# The server defaults to binding 127.0.0.1 for safe local execution. Inside a
# container the port must be reachable through the published mapping, so bind to
# all interfaces here. Deployments can still override BRAVE_MCP_HOST.
ENV BRAVE_MCP_HOST=0.0.0.0
RUN npm ci --ignore-scripts --omit-dev
USER node
ENTRYPOINT ["node", "dist/index.js"]