Skip to content

Commit dc87fff

Browse files
committed
fix: update dockerfile and dockerignore to new github-action dockerfile
1 parent d0141a8 commit dc87fff

File tree

2 files changed

+26
-40
lines changed

2 files changed

+26
-40
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ pnpm-lock.yaml
8484
# Action files (for main CLI docker image)
8585
action.yml
8686
action-template.yml
87-
github-action
8887

8988
# Test directories and files
9089
test-alpine-fix

github-action/Dockerfile

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,39 @@
1-
# Stage 1: Build stage with Node setup
2-
FROM node:18-alpine as build
1+
# Stage 1: Build
2+
FROM node:20-alpine AS build
3+
WORKDIR /app
34

4-
# Copy the source code
5-
COPY ./ /tmp/source_code
5+
# Copy package files first for better caching
6+
COPY package*.json ./
67

7-
# Install dependencies
8-
RUN cd /tmp/source_code && npm install --ignore-scripts
8+
# Install all dependencies (including dev dependencies for build)
9+
RUN npm ci --ignore-scripts
910

10-
# Build the source code
11-
RUN cd /tmp/source_code && npm run build
11+
# Copy only necessary files for build
12+
COPY src/ ./src/
13+
COPY assets/ ./assets/
14+
COPY scripts/ ./scripts/
15+
COPY bin/ ./bin/
16+
COPY tsconfig.json ./
1217

13-
# create libraries directory
14-
RUN mkdir -p /libraries
18+
# Build the application
19+
RUN npm run build && \
20+
npm prune --omit=dev && \
21+
rm -rf test docs .git tmp node_modules/.cache
1522

16-
# Copy the lib, bin, node_modules, and package.json files to the /libraries directory
17-
RUN cp -r /tmp/source_code/lib /libraries
18-
RUN cp -r /tmp/source_code/assets /libraries
19-
RUN cp /tmp/source_code/package.json /libraries
20-
RUN cp /tmp/source_code/package-lock.json /libraries
21-
RUN cp /tmp/source_code/oclif.manifest.json /libraries
22-
23-
# Copy the bin directory to the /libraries directory
24-
RUN cp -r /tmp/source_code/bin /libraries
25-
26-
# Remove everything inside /tmp
27-
RUN rm -rf /tmp/*
28-
29-
FROM node:18-alpine
23+
# Stage 2: Runtime
24+
FROM node:20-alpine
3025

3126
# Install necessary packages
32-
RUN apk add --no-cache bash git
33-
34-
# Copy the libraries directory from the build stage
35-
COPY --from=build /libraries /libraries
36-
37-
RUN cd /libraries && npm install --production --ignore-scripts
38-
39-
# Create a non-root user
40-
# RUN addgroup -S myuser && adduser -S myuser -G myuser
27+
RUN apk update && apk add --no-cache bash git && rm -rf /var/cache/apk/*
4128

42-
# Create a script that runs the desired command
43-
RUN ln -s /libraries/bin/run_bin /usr/local/bin/asyncapi
29+
WORKDIR /app
4430

45-
# Make the script executable
46-
RUN chmod +x /usr/local/bin/asyncapi
31+
# Copy built application from build stage
32+
COPY --from=build /app ./
4733

48-
# Change ownership to non-root user
49-
# RUN chown -R myuser:myuser /libraries /usr/local/bin/asyncapi || echo "Failed to change ownership"
34+
# Create symlink for global access
35+
RUN ln -s /app/bin/run_bin /usr/local/bin/asyncapi && \
36+
chmod +x /usr/local/bin/asyncapi
5037

5138
# Copy the entrypoint script
5239
COPY github-action/entrypoint.sh /entrypoint.sh

0 commit comments

Comments
 (0)