ci: harden Dockerfile and workflow security

This commit is contained in:
Doan Minh Tu
2026-03-11 06:49:10 +07:00
parent aa2b83e1f6
commit 91c1bc848e
3 changed files with 13 additions and 1 deletions

6
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly

View File

@@ -63,3 +63,5 @@ jobs:
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
platforms: linux/amd64 platforms: linux/amd64
provenance: false
sbom: false

View File

@@ -5,6 +5,7 @@ COPY package*.json ./
RUN if [ -f package-lock.json ]; then npm ci --no-audit --no-fund; else npm install --no-audit --no-fund; fi RUN if [ -f package-lock.json ]; then npm ci --no-audit --no-fund; else npm install --no-audit --no-fund; fi
COPY . ./ COPY . ./
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build RUN npm run build
FROM node:20-alpine AS runner FROM node:20-alpine AS runner
@@ -15,15 +16,18 @@ LABEL org.opencontainers.image.title="9router"
ENV NODE_ENV=production ENV NODE_ENV=production
ENV PORT=20128 ENV PORT=20128
ENV HOSTNAME=0.0.0.0 ENV HOSTNAME=0.0.0.0
ENV NEXT_TELEMETRY_DISABLED=1
# Runtime writable location for localDb when DATA_DIR is configured to /app/data # Runtime writable location for localDb when DATA_DIR is configured to /app/data
RUN mkdir -p /app/data RUN mkdir -p /app/data && chown node:node /app/data
COPY --from=builder /app/public ./public COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/static ./.next/static COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/.next/standalone ./ COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/open-sse ./open-sse COPY --from=builder /app/open-sse ./open-sse
USER node
EXPOSE 20128 EXPOSE 20128
CMD ["node", "server.js"] CMD ["node", "server.js"]