- adds a Dockerfile to build the app in container
- adds app to the docker-compose.yml file
This commit is contained in:
21
Dockerfile
Normal file
21
Dockerfile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Use Node.js 24 slim image
|
||||||
|
FROM node:24-slim
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install dependencies first (for better caching)
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# Copy the rest of the code
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build project (for production)
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Expose port if needed (optional, e.g., 3000)
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
# Run app in production mode
|
||||||
|
CMD ["node", "dist/index.js"]
|
@ -7,6 +7,20 @@ services:
|
|||||||
- "27017:27017"
|
- "27017:27017"
|
||||||
volumes:
|
volumes:
|
||||||
- mongo_data:/data/db
|
- mongo_data:/data/db
|
||||||
|
app:
|
||||||
|
build: .
|
||||||
|
container_name: dailytrends_app
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
environment:
|
||||||
|
- MONGO_URI=mongodb://mongo:27017/dailytrends
|
||||||
|
depends_on:
|
||||||
|
- mongo
|
||||||
|
volumes:
|
||||||
|
- .:/app
|
||||||
|
- /app/node_modules
|
||||||
|
command: npm run dev # for development
|
||||||
|
# change to "npm start" for production
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
mongo_data:
|
mongo_data:
|
||||||
|
Reference in New Issue
Block a user