Skip to content

Commit aa7c8cb

Browse files
committed
Update npm workflow to use existing Dockerfile from repository
- Remove automatic Dockerfile generation from npm-release-reusable.yml - Add check to verify Dockerfile exists before building - Add support for Docker build arguments via docker-build-args parameter - Configure Sandbox workflow with REFRAME_API_URL build argument - Workflow now respects and uses the existing Dockerfile in the Sandbox repository
1 parent 4500b34 commit aa7c8cb

2 files changed

Lines changed: 18 additions & 49 deletions

File tree

.github/workflows/npm-release-reusable.yml

Lines changed: 17 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ on:
3131
description: 'Docker image name (required if docker-enabled)'
3232
required: false
3333
type: string
34+
docker-build-args:
35+
description: 'Docker build arguments (e.g., "ARG1=value1 ARG2=value2")'
36+
required: false
37+
type: string
38+
default: ''
3439
secrets:
3540
GH_PAT:
3641
required: true
@@ -97,64 +102,27 @@ jobs:
97102
echo "Please update the version in package.json before releasing"
98103
exit 1
99104
100-
- name: Create Dockerfile if not exists
105+
- name: Check Dockerfile exists
101106
if: inputs.docker-enabled && !inputs.dry-run
102107
run: |
103108
if [ ! -f Dockerfile ]; then
104-
cat > Dockerfile << 'EOF'
105-
# Build stage
106-
FROM node:${{ inputs.node-version }}-alpine AS builder
107-
108-
WORKDIR /app
109-
110-
# Copy package files
111-
COPY ${{ inputs.working-directory }}/package*.json ./
112-
113-
# Install dependencies
114-
RUN npm ci --only=production
115-
116-
# Copy application files
117-
COPY ${{ inputs.working-directory }}/ ./
118-
119-
# Build the application
120-
RUN npm run build
121-
122-
# Runtime stage
123-
FROM node:${{ inputs.node-version }}-alpine
124-
125-
# Install dumb-init for proper signal handling
126-
RUN apk add --no-cache dumb-init
127-
128-
# Create non-root user
129-
RUN addgroup -g 1001 -S nodejs && \
130-
adduser -S nodejs -u 1001
131-
132-
WORKDIR /app
133-
134-
# Copy built application from builder
135-
COPY --from=builder --chown=nodejs:nodejs /app ./
136-
137-
# Switch to non-root user
138-
USER nodejs
139-
140-
# Expose port (adjust as needed)
141-
EXPOSE 3000
142-
143-
# Use dumb-init to handle signals properly
144-
ENTRYPOINT ["dumb-init", "--"]
145-
146-
# Start the application
147-
CMD ["npm", "start"]
148-
EOF
149-
echo "Created Dockerfile"
109+
echo "Error: Dockerfile not found in repository root"
110+
echo "Please ensure a Dockerfile exists in the repository before enabling Docker builds"
111+
exit 1
150112
else
151-
echo "Dockerfile already exists"
113+
echo "Dockerfile found, proceeding with build"
152114
fi
153115
154116
- name: Build Docker image
155117
if: inputs.docker-enabled && !inputs.dry-run
156118
run: |
157-
docker build -t ${{ inputs.docker-image-name }}:${{ steps.get_version.outputs.version }} .
119+
BUILD_ARGS=""
120+
if [ -n "${{ inputs.docker-build-args }}" ]; then
121+
for arg in ${{ inputs.docker-build-args }}; do
122+
BUILD_ARGS="$BUILD_ARGS --build-arg $arg"
123+
done
124+
fi
125+
docker build $BUILD_ARGS -t ${{ inputs.docker-image-name }}:${{ steps.get_version.outputs.version }} .
158126
docker tag ${{ inputs.docker-image-name }}:${{ steps.get_version.outputs.version }} ${{ inputs.docker-image-name }}:latest
159127
160128
- name: Log in to Azure Container Registry

.github/workflows/release-sandbox.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
dry-run: ${{ inputs.dry_run }}
2020
docker-enabled: true
2121
docker-image-name: sandbox
22+
docker-build-args: 'REFRAME_API_URL=http://localhost:3000'
2223
secrets:
2324
GH_PAT: ${{ secrets.GH_PAT }}
2425
ACR_URL: ${{ secrets.ACR_URL }}

0 commit comments

Comments
 (0)