Skip to content

Commit

Permalink
style: chande docker image file structure
Browse files Browse the repository at this point in the history
  • Loading branch information
rithask committed May 12, 2024
1 parent 6ef7330 commit b3ff1d2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
FROM node:alpine

# Set the working directory inside the container for the backend
WORKDIR /usr/src/app/backend
WORKDIR /app

# Create log directory for the backend
RUN mkdir -p /usr/src/app/log
RUN chmod -R 777 /usr/src/app/log
RUN mkdir -p /app/logs
RUN chmod -R 777 /app/logs

# Copy the backend package files to the working directory
COPY backend/package*.json ./
Expand All @@ -18,7 +18,7 @@ RUN npm install --production
COPY backend/ ./

# Set the working directory for the frontend build
WORKDIR /usr/src/app/frontend
WORKDIR /app/frontend

# Copy the frontend package files to the frontend directory
COPY frontend/package*.json ./
Expand All @@ -30,12 +30,12 @@ RUN npm install
COPY frontend/ ./

# Set the working directory to backend
WORKDIR /usr/src/app/backend
WORKDIR /app

# Build the frontend
RUN npm run build:ui
RUN npm run build:ui:docker

# Expose the necessary port for the backend
EXPOSE 3001

CMD ["npm", "start"]
CMD ["node", "index.js"]
3 changes: 2 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"start": "node index",
"dev": "nodemon index",
"test": "echo \"Error: no test specified\" && exit 1",
"build:ui": "rm -rf dist && cd ../frontend && npm run build && cp -r dist ../backend"
"build:ui": "rm -rf dist && cd ../frontend && npm run build && cp -r dist ../backend",
"build:ui:docker": "rm -rf dist && cd ./frontend && npm run build && cp -r dist ../"
},
"license": "ISC",
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
services:
app:
container_name: ktu-grade-aggregator
build: .
container_name: ktu-results-aggregator
image: ghcr.io/rithask/ktu-results-aggregator:latest
ports:
- "3001:3001"
volumes:
- ./logs:/usr/src/app/log
- ./logs:/app/logs
environment:
- MONGODB_URI=${MONGODB_URI}
- NODE_ENV=${NODE_ENV:-production}
Expand Down

0 comments on commit b3ff1d2

Please sign in to comment.