Skip to content

Commit

Permalink
adding docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
edmdz committed Aug 24, 2024
1 parent 95499e1 commit 36fbacb
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docker-composer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3.8'

services:
api:
build:
context: ./api
dockerfile: Dockerfile
ports:
- "3000:3000"
environment:
- NODE_ENV=production

web:
build:
context: ./web
dockerfile: Dockerfile
ports:
- "80:80"
38 changes: 38 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Build stage
FROM node:18-alpine AS build

WORKDIR /app

# Copy package.json and package-lock.json first to leverage Docker cache
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy remaining files
COPY . .

# Build the project
RUN npm run build

# Verify that the dist directory exists and contains files
RUN ls -la /app/dist

# Production stage
FROM nginx:alpine

# Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*

# Copy the build output to the Nginx HTML directory
COPY --from=build /app/dist /usr/share/nginx/html

# Expose the default Nginx port
EXPOSE 80

# Add a health check (optional)
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost/ || exit 1

# Start Nginx
CMD ["nginx", "-g", "daemon off;"]
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,9 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"vite": "^5.1.0"
},
"optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "4.9.5"
}

}

0 comments on commit 36fbacb

Please sign in to comment.