Skip to content

Commit

Permalink
Npm install now works
Browse files Browse the repository at this point in the history
  • Loading branch information
Sinan-96 committed Sep 16, 2024
1 parent 57ad5be commit f00b5f9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ secrets.ACR_ENDPOINT }}/${{ env.IMAGE_NAME }}:V1
tags: ${{ secrets.AZURE_URL }}/incstats:V2
file: Dockerfile
build-args: |
DATABASE_URL=your_database_url
46 changes: 21 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
# Use Node.js base image
FROM node:20-bullseye-slim as base
FROM node:20-bullseye-slim

# Define environment variables
ARG DATABASE_URL
ENV DATABASE_URL=$DATABASE_URL
ENV NODE_ENV=production

# Setup production node_modules
FROM base as production-deps
# Set working directory
# Create app directory
WORKDIR /myapp

COPY package.json package-lock.json ./
RUN rm -rf /myapp/node_modules && npm install
# Copy package.json
COPY package.json ./

# Debug: List node_modules
RUN ls -la /myapp/node_modules && ls -la /myapp/node_modules/@slack/bolt
# Set npm registry to the public registry
RUN npm config set registry https://registry.npmjs.org/

from base
# Install dependencies with verbose logging
RUN npm install --verbose

WORKDIR /myapp
# Check if dotenv is installed
RUN npm list dotenv

# Debug: Show the contents of package.json
RUN echo "Contents of package.json:" && cat package.json

# Copy the rest of the application code without overwriting node_modules
COPY --from=production-deps /myapp/node_modules /myapp/node_modules
COPY app/ ./app/
COPY package.json package-lock.json ./
# Check node_modules content
RUN echo "Contents of node_modules after npm install:" && ls -la /myapp/node_modules

# Set runtime environment variables
ENV DATABASE_URL=$DATABASE_URL
ENV NODE_ENV=production
# Check if dotenv is in node_modules
RUN echo "Contents of dotenv after npm install:" && ls -la /myapp/node_modules/dotenv || echo "dotenv not found"

EXPOSE 80
# Copy the application source code
COPY . .

EXPOSE 8080
# Command to run the app
CMD ["npm", "start"]
CMD ["npm", "start"]

0 comments on commit f00b5f9

Please sign in to comment.