Skip to content

Commit

Permalink
chore: reduce docker image size
Browse files Browse the repository at this point in the history
  • Loading branch information
7185 committed Nov 30, 2024
1 parent cee2144 commit 33f1189
Show file tree
Hide file tree
Showing 20 changed files with 482 additions and 424 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ RUN apk add --update --no-cache icu-libs && \
python -m venv /venv && \
pip install --no-cache-dir -r /backend/requirements.txt && \
prisma generate --schema /backend/prisma/schema.prisma --generator client-py && \
rm -r /root/.cache/prisma /root/.cache/prisma-python/nodeenv /root/.npm && \
chown nobody: -R /root /backend
CMD ["hypercorn", "--config", "hypercorn.toml", "app:app"]
VOLUME ["/app.db"]
Expand All @@ -39,9 +40,11 @@ COPY package.json package-lock.json /root/
RUN npm -w backend ci && \
npx -w backend prisma generate --generator client && \
npm -w backend run build && \
mv backend/dist / && \
npm -w backend prune --omit=dev && \
rm -r .npm && \
cp -r backend/dist / && \
npx -y nm-prune --force && \
rm package*json && \
rm -r .cache .npm backend && \
chown nobody: -R /root /dist /static
CMD ["node", "/dist/main"]
VOLUME ["/app.db"]
Expand Down
2 changes: 1 addition & 1 deletion action-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@typescript-eslint/eslint-plugin": "^8.10.0",
"@typescript-eslint/parser": "^8.10.0",
"@vitest/coverage-v8": "^2.1.6",
"eslint": "^9.15.0",
"eslint": "^9.16.0",
"globals": "^15.12.0",
"prettier": "^3.4.1",
"ts-node": "^10.9.2",
Expand Down
48 changes: 16 additions & 32 deletions action-parser/src/action.visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,8 @@ class ActionVisitor extends BaseActionVisitor {
resource: ctx.Resource.map((identToken: IToken) => identToken.image)[0]
}
const args = ctx.coronaArgs?.map((arg) => this.visit(arg))[0]
if (args != null) {
args.forEach((arg: object) => {
Object.assign(res, arg)
})
if (args) {
Object.assign(res, ...args)
}
return res
}
Expand All @@ -162,10 +160,8 @@ class ActionVisitor extends BaseActionVisitor {
commandType: 'light'
}
const args = ctx.lightArgs?.map((arg) => this.visit(arg))[0]
if (args != null) {
args.forEach((arg: object) => {
Object.assign(res, arg)
})
if (args) {
Object.assign(res, ...args)
}
return res
}
Expand All @@ -176,10 +172,8 @@ class ActionVisitor extends BaseActionVisitor {
url: ctx.Resource.map((identToken) => identToken.image)[0]
}
const args = ctx.mediaArgs?.map((arg) => this.visit(arg))[0]
if (args != null) {
args.forEach((arg: object) => {
Object.assign(res, arg)
})
if (args) {
Object.assign(res, ...args)
}
return res
}
Expand All @@ -202,10 +196,8 @@ class ActionVisitor extends BaseActionVisitor {
}

const args = ctx.moveArgs?.map((arg: CstNode) => this.visit(arg))[0]
if (args != null) {
args.forEach((arg: object) => {
Object.assign(res, arg)
})
if (args) {
Object.assign(res, ...args)
}
return res
}
Expand All @@ -230,10 +222,8 @@ class ActionVisitor extends BaseActionVisitor {
resource: ctx.Resource.map((identToken) => identToken.image)[0]
}
const args = ctx.pictureArgs?.map((arg) => this.visit(arg))[0]
if (args != null) {
args.forEach((arg: object) => {
Object.assign(res, arg)
})
if (args) {
Object.assign(res, ...args)
}
return res
}
Expand All @@ -256,10 +246,8 @@ class ActionVisitor extends BaseActionVisitor {
}

const args = ctx.moveArgs?.map((arg: CstNode) => this.visit(arg))[0]
if (args != null) {
args.forEach((arg: object) => {
Object.assign(res, arg)
})
if (args) {
Object.assign(res, ...args)
}
return res
}
Expand All @@ -284,10 +272,8 @@ class ActionVisitor extends BaseActionVisitor {
text = text.replace(/(^"|"$)/g, '')
Object.assign(res, {text})
}
if (args != null) {
args.forEach((arg: object) => {
Object.assign(res, arg)
})
if (args) {
Object.assign(res, ...args)
}
return res
}
Expand Down Expand Up @@ -344,10 +330,8 @@ class ActionVisitor extends BaseActionVisitor {
texture: ctx.Resource.map((identToken) => identToken.image)[0]
}
const args = ctx.textureArgs?.map((arg) => this.visit(arg))[0]
if (args != null) {
args.forEach((arg: object) => {
Object.assign(res, arg)
})
if (args) {
Object.assign(res, ...args)
}
return res
}
Expand Down
14 changes: 7 additions & 7 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"@fastify/static": "^7.0.4",
"@nestjs/axios": "^3.1.2",
"@nestjs/cache-manager": "^2.3.0",
"@nestjs/common": "^10.4.11",
"@nestjs/core": "^10.4.11",
"@nestjs/common": "^10.4.12",
"@nestjs/core": "^10.4.12",
"@nestjs/jwt": "^10.2.0",
"@nestjs/platform-fastify": "^10.4.11",
"@nestjs/platform-ws": "^10.4.11",
"@nestjs/platform-fastify": "^10.4.12",
"@nestjs/platform-ws": "^10.4.12",
"@nestjs/serve-static": "^4.0.2",
"@nestjs/websockets": "^10.4.11",
"@nestjs/websockets": "^10.4.12",
"@prisma/client": "^6.0.0",
"axios": "^1.7.8",
"cache-manager": "^5.7.6",
Expand All @@ -50,7 +50,7 @@
"@eslint/js": "^9.13.0",
"@nestjs/cli": "^10.4.8",
"@nestjs/schematics": "^10.2.3",
"@nestjs/testing": "^10.4.11",
"@nestjs/testing": "^10.4.12",
"@swc/cli": "^0.5.1",
"@swc/core": "^1.9.3",
"@types/node": "^20.17.7",
Expand All @@ -59,7 +59,7 @@
"@typescript-eslint/eslint-plugin": "^8.10.0",
"@typescript-eslint/parser": "^8.10.0",
"@vitest/coverage-v8": "^2.1.6",
"eslint": "^9.15.0",
"eslint": "^9.16.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.12.0",
Expand Down
2 changes: 1 addition & 1 deletion bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@types/ws": "^8.5.13",
"@typescript-eslint/eslint-plugin": "^8.10.0",
"@typescript-eslint/parser": "^8.10.0",
"eslint": "^9.15.0",
"eslint": "^9.16.0",
"globals": "^15.12.0",
"prettier": "^3.4.1",
"ts-node": "^10.9.2",
Expand Down
8 changes: 8 additions & 0 deletions frontend/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
},
"configurations": {
"production": {
"optimization": {
"scripts": true,
"styles": {
"minify": true,
"inlineCritical": false
},
"fonts": true
},
"budgets": [
{
"type": "initial",
Expand Down
8 changes: 4 additions & 4 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"linkify-string": "^4.1.4",
"linkifyjs": "^4.1.4",
"rxjs": "~7.8.1",
"three": "^0.170.0",
"three": "^0.171.0",
"three-mesh-bvh": "^0.8.3",
"three-rwx-loader": "^0.12.4",
"tslib": "^2.8.1"
Expand All @@ -48,12 +48,12 @@
"@types/three": "^0.170.0",
"@types/webgl2": "^0.0.11",
"@typescript-eslint/types": "^8.10.0",
"angular-eslint": "^18.4.2",
"eslint": "^9.15.0",
"angular-eslint": "^19.0.0",
"eslint": "^9.16.0",
"patch-package": "^8.0.0",
"prettier": "^3.4.1",
"ts-node": "^10.9.2",
"typescript": "~5.5.4",
"typescript": ">=5.5.0 <5.7.0",
"typescript-eslint": "^8.16.0"
}
}
2 changes: 1 addition & 1 deletion frontend/src/app/auth/auth.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {MatButton, MatIconButton} from '@angular/material/button'
import {MatError, MatInput, MatSuffix} from '@angular/material/input'
import {MatFormField, MatLabel} from '@angular/material/form-field'
import {FaIconComponent} from '@fortawesome/angular-fontawesome'
import {finalize} from 'rxjs/operators'
import {finalize} from 'rxjs'
import {HttpService} from '../network'
import {LogoComponent} from '../logo/logo.component'
import {
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/engine/inputsystem.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {inject, Injectable} from '@angular/core'
import {fromEvent} from 'rxjs'
import {filter, tap} from 'rxjs/operators'
import {filter, fromEvent, tap} from 'rxjs'
import {SettingsService} from '../settings/settings.service'

const pressedKeys = [
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/network/http.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import {inject} from '@angular/core'
import {HttpErrorResponse, HttpHeaders} from '@angular/common/http'
import type {HttpInterceptorFn, HttpResponse} from '@angular/common/http'
import {HttpService} from './http.service'
import {EMPTY, throwError} from 'rxjs'
import {EMPTY, catchError, mergeMap, throwError} from 'rxjs'
import {environment} from '../../environments/environment'
import {catchError, mergeMap} from 'rxjs/operators'

const authUrl = `${environment.url.server}/auth`

Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/network/http.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {throwError} from 'rxjs'
import {catchError, map, tap, throwError} from 'rxjs'
import {computed, inject, Injectable, signal} from '@angular/core'
import {HttpClient} from '@angular/common/http'
import type {HttpResponse} from '@angular/common/http'
import {Router} from '@angular/router'
import {environment} from '../../environments/environment'
import {User} from '../user'
import {catchError, map, tap} from 'rxjs/operators'

export type PropEntry = [
number,
Expand Down
Loading

0 comments on commit 33f1189

Please sign in to comment.