diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e59c418 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +node_modules +dist +.git +.gitignore +npm-debug.log +.DS_Store +*.local +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0584fc0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM node:20-alpine AS build + +WORKDIR /app + +COPY package*.json ./ +RUN npm ci + +COPY . . +RUN npm run build + +FROM nginx:1.27-alpine AS production + +COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=build /app/dist /usr/share/nginx/html + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/README.md b/README.md index 9af5f60..f1153a5 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,26 @@ npm run dev The app will open at [http://localhost:5173](http://localhost:5173) +### Docker (Production) + +```bash +# Build and run +docker compose up --build -d + +# Open the app +http://localhost:8080 + +# Stop containers +docker compose down +``` + +You can also run without Compose: + +```bash +docker build -t foodsaver-ai . +docker run --rm -p 8080:80 foodsaver-ai +``` + ## ⚙️ CI/CD (GitHub Actions) This repository now includes: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..6aec363 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +services: + app: + build: + context: . + target: production + ports: + - "8080:80" + restart: unless-stopped diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..8700dee --- /dev/null +++ b/nginx.conf @@ -0,0 +1,11 @@ +server { + listen 80; + server_name localhost; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } +}