mirror of
https://github.com/robonen/canvas-3d.git
synced 2026-03-20 02:44:40 +00:00
@@ -2,6 +2,7 @@
|
|||||||
*
|
*
|
||||||
|
|
||||||
# Allow files and directories
|
# Allow files and directories
|
||||||
|
!.env
|
||||||
!src
|
!src
|
||||||
!nuxt.config.ts
|
!nuxt.config.ts
|
||||||
!tsconfig.json
|
!tsconfig.json
|
||||||
|
|||||||
13
.env.example
13
.env.example
@@ -1 +1,12 @@
|
|||||||
NUXT_API_HOST=https://localhost
|
APP_NAME=canvas-3d
|
||||||
|
|
||||||
|
# Infrastucture config
|
||||||
|
FORWARD_APP_PORT=3000
|
||||||
|
|
||||||
|
FORWARD_DB_PORT=5432
|
||||||
|
DB_USERNAME=postgres
|
||||||
|
DB_PASSWORD=password
|
||||||
|
DB_DATABASE=c3d
|
||||||
|
|
||||||
|
# App config
|
||||||
|
NUXT_API_HOST=http://localhost/api
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -19,3 +19,4 @@ node_modules
|
|||||||
|
|
||||||
# Environment
|
# Environment
|
||||||
.env
|
.env
|
||||||
|
.env
|
||||||
|
|||||||
@@ -5,9 +5,10 @@ FROM node:${NODE_VERSION} AS builder
|
|||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
|
||||||
|
# See .dockerignore
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN npm ci && npm run build && npm cache clean --force
|
RUN npm cache clean --force && npm ci && npm run build
|
||||||
|
|
||||||
# Stage 2: Run the application
|
# Stage 2: Run the application
|
||||||
FROM node:${NODE_VERSION}
|
FROM node:${NODE_VERSION}
|
||||||
@@ -19,7 +20,6 @@ COPY --from=builder /build/src/.output .
|
|||||||
ENV HOST=0.0.0.0
|
ENV HOST=0.0.0.0
|
||||||
ENV PORT=3000
|
ENV PORT=3000
|
||||||
|
|
||||||
VOLUME /app
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
CMD ["node", "./server/index.mjs"]
|
ENTRYPOINT ["node", "./server/index.mjs"]
|
||||||
|
|||||||
36
Taskfile.yml
Normal file
36
Taskfile.yml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
dotenv: [ '.env' ]
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
make:env:
|
||||||
|
cmds:
|
||||||
|
- '[ ! -f .env ] && cp .env.example .env; exit 0'
|
||||||
|
|
||||||
|
make:install:
|
||||||
|
cmds:
|
||||||
|
- '[ ! -d node_modules ] && npm install; exit 0'
|
||||||
|
|
||||||
|
local:run:
|
||||||
|
ignore_error: true
|
||||||
|
deps: [ make:env, make:install ]
|
||||||
|
cmds:
|
||||||
|
- npm run dev
|
||||||
|
|
||||||
|
docker:run:
|
||||||
|
deps: [ make:env ]
|
||||||
|
cmds:
|
||||||
|
- docker-compose -p $APP_NAME up -d
|
||||||
|
|
||||||
|
docker:stop:
|
||||||
|
cmds:
|
||||||
|
- docker-compose -p $APP_NAME down
|
||||||
|
|
||||||
|
docker:stop:rm:
|
||||||
|
cmds:
|
||||||
|
- docker-compose -p $APP_NAME down -v --remove-orphans
|
||||||
|
|
||||||
|
test:performance:
|
||||||
|
ignore_error: true
|
||||||
|
cmds:
|
||||||
|
- docker run --rm -i --network host grafana/k6 run --vus 1000 --duration 30s - < ./src/tests/performance/test_main_page.js
|
||||||
50
config/nginx/proxy_lb.conf
Normal file
50
config/nginx/proxy_lb.conf
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
# default docker DNS
|
||||||
|
resolver 127.0.0.11 ipv6=off valid=10s;
|
||||||
|
|
||||||
|
# . files
|
||||||
|
location ~ /\.(?!well-known) {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
|
||||||
|
# logging
|
||||||
|
access_log /var/log/nginx/access.log;
|
||||||
|
error_log /var/log/nginx/error.log warn;
|
||||||
|
|
||||||
|
# reverse proxy
|
||||||
|
location / {
|
||||||
|
proxy_pass http://app:3000$request_uri;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
|
||||||
|
# proxy headers
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Host $server_name;
|
||||||
|
|
||||||
|
# proxy timeouts
|
||||||
|
proxy_connect_timeout 60s;
|
||||||
|
proxy_send_timeout 60s;
|
||||||
|
proxy_read_timeout 60s;
|
||||||
|
}
|
||||||
|
|
||||||
|
# favicon.ico
|
||||||
|
location = /favicon.ico {
|
||||||
|
log_not_found off;
|
||||||
|
}
|
||||||
|
|
||||||
|
# robots.txt
|
||||||
|
location = /robots.txt {
|
||||||
|
log_not_found off;
|
||||||
|
}
|
||||||
|
|
||||||
|
# gzip
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_proxied any;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
|
||||||
|
}
|
||||||
60
docker-compose.yml
Normal file
60
docker-compose.yml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
|
||||||
|
proxy_lb:
|
||||||
|
container_name: proxy_lb
|
||||||
|
image: nginx:latest
|
||||||
|
ports:
|
||||||
|
- '${PROXY_PORT:-80}:80'
|
||||||
|
- '${PROXY_PORT_SSL:-443}:443'
|
||||||
|
volumes:
|
||||||
|
- './config/nginx/proxy_lb.conf:/etc/nginx/conf.d/default.conf'
|
||||||
|
networks:
|
||||||
|
- c3d_net
|
||||||
|
depends_on:
|
||||||
|
- app
|
||||||
|
|
||||||
|
app:
|
||||||
|
# container_name: app
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
replicas: 2
|
||||||
|
expose:
|
||||||
|
- '${FORWARD_APP_PORT:-3000}'
|
||||||
|
# ports:
|
||||||
|
# - '${FORWARD_APP_PORT:-3000}:3000'
|
||||||
|
networks:
|
||||||
|
- c3d_net
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
|
||||||
|
db:
|
||||||
|
container_name: db
|
||||||
|
image: 'postgres:latest'
|
||||||
|
ports:
|
||||||
|
- '${FORWARD_DB_PORT:-5432}:5432'
|
||||||
|
environment:
|
||||||
|
PGPASSWORD: '${DB_PASSWORD:-secret}'
|
||||||
|
POSTGRES_DB: '${DB_DATABASE}'
|
||||||
|
POSTGRES_USER: '${DB_USERNAME}'
|
||||||
|
POSTGRES_PASSWORD: '${DB_PASSWORD:-secret}'
|
||||||
|
volumes:
|
||||||
|
- 'c3d_vol:/var/lib/postgresql/data'
|
||||||
|
networks:
|
||||||
|
- c3d_net
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD", "pg_isready", "-q", "-d", "${DB_DATABASE}", "-U", "${DB_USERNAME}" ]
|
||||||
|
retries: 3
|
||||||
|
timeout: 5s
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
c3d_vol:
|
||||||
|
driver: local
|
||||||
|
|
||||||
|
networks:
|
||||||
|
c3d_net:
|
||||||
|
driver: bridge
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
// https://v3.nuxtjs.org/api/configuration/nuxt.config
|
// https://v3.nuxtjs.org/api/configuration/nuxt.config
|
||||||
|
import {defineNuxtConfig} from 'nuxt/config';
|
||||||
import {resolve} from 'path';
|
import {resolve} from 'path';
|
||||||
|
|
||||||
const SRC = resolve(__dirname, 'src');
|
const SRC = resolve(__dirname, 'src');
|
||||||
|
|||||||
3738
package-lock.json
generated
3738
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,11 @@
|
|||||||
{
|
{
|
||||||
|
"name": "canvas3d",
|
||||||
|
"description": "Web application for affine transformations of three-dimensional figures",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/robonen/canvas-3d/issues?q=is:open is:issue label:bug"
|
||||||
|
},
|
||||||
|
"author": "Andrew Robonen <robonenandrew@gmail.com>",
|
||||||
|
"license": "MIT",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "nuxt build",
|
"build": "nuxt build",
|
||||||
@@ -10,7 +17,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vueuse/core": "^9.3.1",
|
"@vueuse/core": "^9.3.1",
|
||||||
"@vueuse/nuxt": "^9.3.1",
|
"@vueuse/nuxt": "^9.3.1",
|
||||||
"nuxt": "3.0.0-rc.11",
|
"nuxt": "^3.0.0",
|
||||||
"sass": "^1.55.0"
|
"sass": "^1.55.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
9
src/server/api/test.ts
Normal file
9
src/server/api/test.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import {defineEventHandler} from 'h3';
|
||||||
|
|
||||||
|
export default defineEventHandler((event) => {
|
||||||
|
console.log('Request received');
|
||||||
|
|
||||||
|
return {
|
||||||
|
api: 'works',
|
||||||
|
};
|
||||||
|
});
|
||||||
7
src/tests/performance/test_main_page.js
Normal file
7
src/tests/performance/test_main_page.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import http from 'k6/http';
|
||||||
|
import {sleep} from 'k6';
|
||||||
|
|
||||||
|
export default function () {
|
||||||
|
http.get('http://localhost');
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user