Skip to content

Commit b1bfc4d

Browse files
committed
Refactor Dockerfile and buildspec.yml for Bun installation and command execution
- Remove direct Bun installation from the Dockerfile and install it as the nextjs user in a globally accessible location in buildspec.yml. - Change the command to start the application from Bun to Node.js for improved compatibility and performance.
1 parent da0b09d commit b1bfc4d

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

apps/web/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@ USER nextjs
7373
EXPOSE 3000
7474

7575
# Start the application
76-
CMD ["bun", "server.js"]
76+
CMD ["node", "server.js"]
7777

apps/web/buildspec.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ phases:
5959
# Use Node.js Alpine for smaller image size
6060
FROM node:18-alpine AS runtime
6161
62-
# Install Bun
63-
RUN apk add --no-cache curl bash && \
64-
curl -fsSL https://bun.sh/install | bash && \
65-
ln -s /root/.bun/bin/bun /usr/local/bin/bun
62+
# Install dependencies for Bun
63+
RUN apk add --no-cache curl bash
6664
6765
WORKDIR /app
6866
@@ -74,16 +72,21 @@ phases:
7472
# Copy the complete standalone build
7573
COPY .next/standalone ./
7674
77-
# Ensure proper permissions
75+
# Create user and set permissions
7876
RUN addgroup -g 1001 -S nodejs && \
7977
adduser -S nextjs -u 1001 && \
8078
chown -R nextjs:nodejs /app
8179
80+
# Install Bun as the nextjs user in a globally accessible location
81+
RUN curl -fsSL https://bun.sh/install | bash -s -- --install-dir=/usr/local && \
82+
chmod +x /usr/local/bin/bun
83+
8284
USER nextjs
8385
8486
EXPOSE 3000
8587
86-
CMD ["bun", "server.js"]
88+
# Use node to run the standalone server.js directly
89+
CMD ["node", "server.js"]
8790
EOF
8891
8992
- docker build -f Dockerfile.runtime -t $IMAGE_REPO_NAME:$IMAGE_TAG .

0 commit comments

Comments
 (0)