Skip to content

Commit

Permalink
feat(Dockerfile): Add build step and run.sh script
Browse files Browse the repository at this point in the history
This commit adds a build step to the Dockerfile, which runs the `npm run build` command. It also introduces a new `run.sh` script that installs dependencies using `npm install` and starts the server with `npm run serve`.
  • Loading branch information
BillChirico committed Nov 6, 2023
1 parent 53ae83e commit 3675ac4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ FROM node:lts-alpine AS deps
WORKDIR /opt/app
# Copy package.json and package-lock.json to the working directory
COPY package.json package-lock.json ./
COPY . .
COPY . /
# Install production dependencies only
RUN npm ci --only=production
# Build the application
RUN npm run build

# Stage 2: Build the application
FROM node:lts-alpine AS builder
Expand All @@ -16,8 +18,6 @@ WORKDIR /opt/app
# Copy node_modules from the "deps" stage
COPY package.json package-lock.json ./
COPY --from=deps /opt/app/node_modules ./node_modules
# Build the application
RUN npm run build

# Stage 3: Create the production image
FROM node:lts-alpine AS runner
Expand All @@ -30,4 +30,4 @@ EXPOSE 5000
COPY --from=builder /opt/app/build ./build
COPY package.json package-lock.json ./
# Define the command to run the application
CMD ["sh", "-l", "-c", "npm run serve"]
CMD run.sh
10 changes: 10 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Navigate to the directory containing your project's package.json file
# cd /path/to/your/project

# Run npm install to install all dependencies
npm install

# Run npm run serve to start the server
npm run serve

0 comments on commit 3675ac4

Please sign in to comment.