Skip to content

backend to docker-compose added #296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ node_modules
# local env files
*.env*
!example.env
!example.env.backend

# local bugs log
bugs.bug
Expand All @@ -37,4 +38,6 @@ yarn-error.log*
# Lock files
# Вызвало сбой сборки докера
# пока вернем до прихода DevOps
# package-lock.json*
# package-lock.json*

docker-compose.override.yaml
22 changes: 22 additions & 0 deletions Dockerfile.backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# syntax = docker/dockerfile:1.3
ARG NODE_VERSION=16



FROM node:${NODE_VERSION}-alpine AS deps
WORKDIR /var/www
COPY package.json package-lock.json ./
# RUN --mount=type=cache,target=/root/.npm npm install
RUN npm install



FROM node:${NODE_VERSION}-alpine AS builder
WORKDIR /var/www
COPY --from=deps /var/www .
COPY . .
ENV NODE_ENV=production
# RUN --mount=type=cache,target=./node_modules/.cache npm run build
RUN npm run build
CMD ["node", "src/backend/main.mjs"]
EXPOSE 3030
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ docker-compose up --build
```
DocHub станет доступен по адресу [http://localhost:8080/main](http://localhost:8080/main)

### Локальное развертывание в режиме client-server

Выполните команды:
```
cp docker-compose.override.backend.yaml docker-compose.override.yaml
cp example.env.backend .env
docker-compose up --build
```
DocHub станет доступен по адресу [http://localhost:8080/main](http://localhost:8080/main), api сервера [http://localhost:3030/](http://localhost:3030/)

### Сборка из исходников для продакшен

Проект является VueJS SPA приложением. В качестве backend пользуется GitLab.
Expand Down
20 changes: 20 additions & 0 deletions docker-compose.override.backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: "3.8"

services:
nginx:
container_name: dochub-frontend
image: dochub-frontend
build:
context: .
dockerfile: Dockerfile
target: nginx
ports:
- "8080:8080"
backend:
container_name: dochub-backend
image: dochub-backend
build:
context: .
dockerfile: Dockerfile.backend
ports:
- "3030:3030"
3 changes: 3 additions & 0 deletions example.env.backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VUE_APP_DOCHUB_MODE=backend
VUE_APP_PLANTUML_SERVER="localhost:8079/svg/"
VUE_APP_DOCHUB_BACKEND_URL="http://localhost:3030"
163 changes: 163 additions & 0 deletions k8s_deploy_example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: dochub-portal
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: dochub-web
name: dochub-web
namespace: dochub-portal
spec:
replicas: 2
selector:
matchLabels:
app: dochub-web
template:
metadata:
labels:
app: dochub-web
spec:
containers:
- image: _IMG_TO_DEPLOY_ # replace with full registry path to builded DocHub image
imagePullPolicy: IfNotPresent
name: dochub-web
ports:
- containerPort: 8080
name: http-port
protocol: TCP
livenessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 5
readinessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 5
resources:
limits:
cpu: 500m
memory: 500Mi
requests:
cpu: 250m
memory: 250Mi
---
- apiVersion: v1
kind: Service
metadata:
name: dochub-web
namespace: dochub-portal
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
selector:
app: dochub-web
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: dochub-web
# uncomment below if you plan to use custom path in pathType.path field
# annotations:
# nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx-ingress # remove if you plan to use defaul ingress-controller or replace with right ingressClassName
rules:
- host: dochub.example.org # replace with right host name
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: dochub-web
port:
number: 8080
---

# BACKEND
# Remove all lines below in case "Frontend only"

apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: dochub-api
name: dochub-api
namespace: dochub-portal
spec:
replicas: 2
selector:
matchLabels:
app: dochub-api
template:
metadata:
labels:
app: dochub-api
spec:
containers:
- image: _IMG_TO_DEPLOY_ # replace with full registry path to builded DocHub backend image
imagePullPolicy: IfNotPresent
name: dochub-api
ports:
- containerPort: 3030
name: api-port
protocol: TCP
livenessProbe:
httpGet:
path: /
port: 3030
initialDelaySeconds: 15
readinessProbe:
httpGet:
path: /
port: 3030
initialDelaySeconds: 15
resources:
limits:
cpu: 500m
memory: 500Mi
requests:
cpu: 250m
memory: 250Mi
---
- apiVersion: v1
kind: Service
metadata:
name: dochub-api
namespace: dochub-portal
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 3030
selector:
app: dochub-api
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: dochub-api
# uncomment below if you plan to use custom path in rules.host.http.paths.pathType.path field
# annotations:
# nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx-ingress # remove if you plan to use defaul ingress-controller or replace with right ingressClassName
rules:
- host: dochub-api.example.org # replace with right host name
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: dochub-api
port:
number: 8080