Feat: docker compose done
This commit is contained in:
31
backend/Dockerfile
Normal file
31
backend/Dockerfile
Normal file
@@ -0,0 +1,31 @@
|
||||
FROM node:22 AS deps
|
||||
|
||||
WORKDIR /app
|
||||
COPY ./package.json ./package-lock.json .
|
||||
RUN npm ci --omit=dev
|
||||
|
||||
#####
|
||||
|
||||
FROM node:22 AS devdeps
|
||||
|
||||
WORKDIR /app
|
||||
COPY ./package.json ./package-lock.json ./tsconfig.json .
|
||||
RUN npm ci
|
||||
|
||||
#####
|
||||
|
||||
FROM node:22 AS build
|
||||
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
COPY --from=devdeps /app/node_modules /app/node_modules
|
||||
RUN npm run build
|
||||
|
||||
#####
|
||||
|
||||
FROM gcr.io/distroless/nodejs22-debian12
|
||||
WORKDIR /app
|
||||
COPY --from=build /app /app
|
||||
COPY --from=deps /app/node_modules /app/node_modules
|
||||
|
||||
CMD ["dist/index.js"]
|
||||
@@ -5,7 +5,7 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "vitest run --coverage",
|
||||
"build": "tsc",
|
||||
"build": "npx tsc",
|
||||
"start": "node dist/index.js",
|
||||
"dev": "concurrently --raw \"tsc -w \" \"nodemon dist/index.js\""
|
||||
},
|
||||
|
||||
24
docker-compose.yml
Normal file
24
docker-compose.yml
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
services:
|
||||
db:
|
||||
image: mongo:8.0
|
||||
volumes:
|
||||
- mongo:/data/db
|
||||
backend:
|
||||
build:
|
||||
context: ./backend
|
||||
environment:
|
||||
PORT: 8888
|
||||
HOST: 0.0.0.0
|
||||
MONGO_CONNECTION_STRING: mongodb://db:27017/todo
|
||||
depends_on:
|
||||
- db
|
||||
frontend:
|
||||
build:
|
||||
context: ./frontend
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf
|
||||
ports:
|
||||
- 8080:80
|
||||
volumes:
|
||||
mongo: {}
|
||||
21
frontend/Dockerfile
Normal file
21
frontend/Dockerfile
Normal file
@@ -0,0 +1,21 @@
|
||||
FROM node:22 AS devdeps
|
||||
|
||||
WORKDIR /app
|
||||
COPY ./package.json ./package-lock.json .
|
||||
RUN npm ci
|
||||
|
||||
#####
|
||||
|
||||
FROM node:22 AS build
|
||||
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
COPY --from=devdeps /app/node_modules /app/node_modules
|
||||
RUN npm run build
|
||||
|
||||
#####
|
||||
|
||||
FROM nginx:1.27.5-alpine-slim
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
@@ -4,7 +4,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"build": "npx tsc && npx vite build",
|
||||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||
"preview": "vite preview",
|
||||
"test:e2e": "playwright test"
|
||||
|
||||
47
nginx.conf
Normal file
47
nginx.conf
Normal file
@@ -0,0 +1,47 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
#access_log /var/log/nginx/host.access.log main;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_pass http://backend:8888;
|
||||
}
|
||||
|
||||
#error_page 404 /404.html;
|
||||
|
||||
# redirect server error pages to the static page /50x.html
|
||||
#
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
|
||||
#
|
||||
#location ~ \.php$ {
|
||||
# proxy_pass http://127.0.0.1;
|
||||
#}
|
||||
|
||||
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
||||
#
|
||||
#location ~ \.php$ {
|
||||
# root html;
|
||||
# fastcgi_pass 127.0.0.1:9000;
|
||||
# fastcgi_index index.php;
|
||||
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
|
||||
# include fastcgi_params;
|
||||
#}
|
||||
|
||||
# deny access to .htaccess files, if Apache's document root
|
||||
# concurs with nginx's one
|
||||
#
|
||||
#location ~ /\.ht {
|
||||
# deny all;
|
||||
#}
|
||||
}
|
||||
Reference in New Issue
Block a user