Updated monorepo building, dockerized
This commit is contained in:
parent
b2603d385d
commit
6ab1de4420
5
.dockerignore
Normal file
5
.dockerignore
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
node_modules/
|
||||||
|
dist/
|
||||||
|
*.log
|
||||||
|
*.md
|
||||||
|
media/
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,3 @@
|
|||||||
pnpm-lock.yaml
|
|
||||||
node_modules/
|
node_modules/
|
||||||
dist/
|
dist/
|
||||||
*.log
|
*.log
|
23
Dockerfile
Normal file
23
Dockerfile
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
FROM node:20-slim AS builder
|
||||||
|
ENV PNPM_HOME="/pnpm"
|
||||||
|
ENV PATH="$PNPM_HOME:$PATH"
|
||||||
|
RUN corepack enable
|
||||||
|
COPY . /app
|
||||||
|
WORKDIR /app
|
||||||
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
|
||||||
|
ARG VITE_WS_URL
|
||||||
|
RUN pnpm run -r build
|
||||||
|
|
||||||
|
FROM builder as back_pruned
|
||||||
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm --filter back --prod deploy pruned
|
||||||
|
|
||||||
|
FROM nginx:alpine-slim as front
|
||||||
|
WORKDIR /usr/share/nginx/html
|
||||||
|
RUN rm -rf ./*
|
||||||
|
COPY --from=builder /app/apps/front/dist .
|
||||||
|
|
||||||
|
FROM node:20-slim as back
|
||||||
|
WORKDIR /app
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
COPY --from=back_pruned /app/pruned .
|
||||||
|
CMD [ "npm", "start" ]
|
32
README.md
32
README.md
@ -8,32 +8,22 @@
|
|||||||
|
|
||||||
Web application for distribution of free classrooms. [Description](./description.md)
|
Web application for distribution of free classrooms. [Description](./description.md)
|
||||||
|
|
||||||
## Deploy
|
## Build instruction
|
||||||
|
|
||||||
Clone repo
|
Production:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://git.dm1sh.ru/dm1sh/roomruler.git
|
docker build . --build-arg "VITE_WS_URL=<Backend url>" --target front --tag roomruler_front
|
||||||
cd roomruler
|
docker build . --build-arg "VITE_WS_URL=<Backend url>" --target back --tag roomruler_back
|
||||||
|
|
||||||
|
docker run -d -e "DATABASE_URL=<CockroachDB connection string>" -p "<Backend public port>:8081" --name roomruler_back roomruler_back
|
||||||
|
docker run -d --name roomruler_front -p "<Frontend public port>:80" roomruler_front
|
||||||
```
|
```
|
||||||
|
|
||||||
Put [CockroachDB](https://www.cockroachlabs.com) certificate to `apps/back/certs`. Copy `apps/back/.env.example` and fill it in. So do with `apps/back/src/db/config.example.ts`
|
Development:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir apps/back/certs/
|
npx pnpm install
|
||||||
cp ../cc-ca.crt apps/back/certs/
|
npx pnpm -r run build
|
||||||
|
npx pnpm -r run dev
|
||||||
cp apps/back/.env.example apps/back/.env
|
|
||||||
$EDITOR apps/back/.env
|
|
||||||
|
|
||||||
cp apps/back/src/db/config.example.ts apps/back/src/db/config.ts
|
|
||||||
$EDITOR apps/back/src/db/config.ts
|
|
||||||
```
|
|
||||||
|
|
||||||
Install dependencies, build and run
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npx pnpm i
|
|
||||||
npx pnpm build
|
|
||||||
npx pnpm start
|
|
||||||
```
|
```
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
DATABASE_URL="postgresql://"
|
|
||||||
PORT=8081
|
|
@ -3,7 +3,6 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc && rollup --config rollup.config.js",
|
"build": "tsc && rollup --config rollup.config.js",
|
||||||
"prestart": "[[ -d dist ]] || pnpm run build",
|
|
||||||
"start": "node dist/index.js",
|
"start": "node dist/index.js",
|
||||||
"dev": "rollup --config rollup.config.dev.js --watch"
|
"dev": "rollup --config rollup.config.dev.js --watch"
|
||||||
},
|
},
|
||||||
@ -16,8 +15,8 @@
|
|||||||
"typescript": "^4.4.2"
|
"typescript": "^4.4.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@roomruler/logger": "workspace:^0.0.0",
|
"@roomruler/logger": "*",
|
||||||
"@roomruler/messages": "workspace:^0.0.0",
|
"@roomruler/messages": "*",
|
||||||
"pg": "^8.7.1",
|
"pg": "^8.7.1",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"typeorm": "^0.2.37",
|
"typeorm": "^0.2.37",
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
export const config = {
|
|
||||||
host: "",
|
|
||||||
username: "",
|
|
||||||
password: "",
|
|
||||||
database: "",
|
|
||||||
};
|
|
@ -1,19 +1,14 @@
|
|||||||
import { Connection, createConnection } from "typeorm";
|
import { Connection, createConnection } from "typeorm";
|
||||||
import fs from "fs";
|
|
||||||
|
|
||||||
import { Room } from "./model";
|
import { Room } from "./model";
|
||||||
import { config } from "./config";
|
|
||||||
|
|
||||||
export { Room };
|
export { Room };
|
||||||
|
|
||||||
export const connect = () =>
|
export const connect = () =>
|
||||||
createConnection({
|
createConnection({
|
||||||
...config,
|
url: process.env.DATABASE_URL,
|
||||||
type: "cockroachdb",
|
type: "cockroachdb",
|
||||||
port: 26257,
|
ssl: true,
|
||||||
ssl: {
|
|
||||||
ca: fs.readFileSync("certs/cc-ca.crt").toString(),
|
|
||||||
},
|
|
||||||
synchronize: true,
|
synchronize: true,
|
||||||
logging: false,
|
logging: false,
|
||||||
entities: [Room],
|
entities: [Room],
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"start": "serve -s dist",
|
"start": "serve -s dist",
|
||||||
"prestart": "[[ -d dist ]] || pnpm run build",
|
|
||||||
"build": "vite build"
|
"build": "vite build"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -16,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@material-ui/core": "^4.12.3",
|
"@material-ui/core": "^4.12.3",
|
||||||
"@roomruler/messages": "workspace:^0.0.0",
|
"@roomruler/messages": "*",
|
||||||
"immer": "^9.0.6",
|
"immer": "^9.0.6",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2"
|
"react-dom": "^17.0.2"
|
||||||
|
@ -1 +0,0 @@
|
|||||||
export const WS_URL = "ws://localhost:8081";
|
|
@ -10,12 +10,11 @@ import {
|
|||||||
isUpdateMessage,
|
isUpdateMessage,
|
||||||
UpdateMessage,
|
UpdateMessage,
|
||||||
} from "@roomruler/messages";
|
} from "@roomruler/messages";
|
||||||
import { WS_URL } from "./config";
|
|
||||||
import { RoomDisplay, RoomState } from "./types/room";
|
import { RoomDisplay, RoomState } from "./types/room";
|
||||||
|
|
||||||
const Context = createContext<ContextValue | undefined>(undefined);
|
const Context = createContext<ContextValue | undefined>(undefined);
|
||||||
|
|
||||||
const ws = new WebSocket(WS_URL);
|
const ws = new WebSocket(import.meta.env.VITE_WS_URL || "ws://localhost:8081");
|
||||||
|
|
||||||
export const RoomContextProvider: FC = ({ children }) => {
|
export const RoomContextProvider: FC = ({ children }) => {
|
||||||
const [state, setState] = useState<ContextData>(defaultState);
|
const [state, setState] = useState<ContextData>(defaultState);
|
||||||
|
@ -3,11 +3,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Web application for distribution of free classrooms",
|
"description": "Web application for distribution of free classrooms",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "pnpm start -r",
|
"clean": "rm -rf node_modules apps/back/node_modules apps/front/node_modules packages/messages/node_modules packages/logger/node_modules apps/back/dist apps/front/dist packages/messages/dist packages/logger/dist"
|
||||||
"build": "pnpm run build -r",
|
|
||||||
"dev": "pnpm run dev -r",
|
|
||||||
"preinstall": "npx -y only-allow pnpm",
|
|
||||||
"clean": "rm -rf node_modules apps/back/node_modules apps/front/node_modules packages/messages/node_modules packages/logger/node_modules apps/back/dist apps/front/dist packages/messages/dist packages/logger/dist pnpm-lock.yaml"
|
|
||||||
},
|
},
|
||||||
"author": "dm1sh",
|
"author": "dm1sh",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
"types": "dist/src/index.d.ts",
|
"types": "dist/src/index.d.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "pnpm run build",
|
|
||||||
"build": "tsc --build"
|
"build": "tsc --build"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
"types": "dist/src/index.d.ts",
|
"types": "dist/src/index.d.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc --build",
|
"build": "tsc --build"
|
||||||
"postinstall": "pnpm run build"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^4.4.2"
|
"typescript": "^4.4.2"
|
||||||
|
2455
pnpm-lock.yaml
generated
Normal file
2455
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,3 @@
|
|||||||
packages:
|
packages:
|
||||||
- "apps/**"
|
- 'packages/*'
|
||||||
- "packages/**"
|
- 'apps/*'
|
@ -25,6 +25,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "./packages/messages/"
|
"path": "./packages/messages/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./packages/logger/"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user