Skip to content
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
56 changes: 25 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
# Build the application
# -> transpile typescript to javascript
FROM node:lts AS builder
FROM node:22-bookworm AS builder

WORKDIR /usr/src/app

COPY package.json ./
RUN corepack enable

# required for native builds
RUN apt-get update && apt-get install -y \
python3 make g++ \
&& rm -rf /var/lib/apt/lists/*

COPY package.json yarn.lock .yarnrc.yml ./

RUN yarn install --immutable

# 🔥 CRITICAL FIX: force native rebuild
RUN yarn add better-sqlite3 --build-from-source

COPY app ./app
COPY tsconfig.json ./
COPY yarn.lock ./
COPY .yarnrc.yml ./
COPY ./app ./app
RUN corepack enable ; yarn set version latest ; yarn install ; yarn build

# Application runner
# -> runs the transpiled code itself
# seperated from builder context to keep image as slim as possible
FROM node:lts-alpine
RUN yarn build


FROM node:22-bookworm-slim

WORKDIR /app
ENV NODE_ENV=production

COPY package.json ./
COPY yarn.lock ./
COPY .yarnrc.yml ./
RUN corepack enable

COPY --from=builder /usr/src/app/node_modules ./node_modules
COPY --from=builder /usr/src/app/dist/app ./app
RUN corepack enable ; yarn set version latest; \
RUN yarn workspaces focus --all --production && rm -rf "$(yarn cache clean)" ; yarn install
# "temporary" fix to allow directory traversal in both docker and non-docker environments
# Can't just change the app directory, as that might break existing directory mounts - so it'll do
RUN cp package.json ./../package.json
EXPOSE 3000
CMD [ "node", "app/launch.js" ]

LABEL \
org.opencontainers.image.vendor="IntellectualSites" \
org.opencontainers.image.title="Arkitektonika" \
org.opencontainers.image.description="A REST repository for NBT data for Minecraft" \
org.opencontainers.image.url="https://github.com/IntellectualSites" \
org.opencontainers.image.source="https://github.com/IntellectualSites/Arkitektonika" \
org.opencontainers.image.licenses="ISC" \
com.docker.image.source.entrypoint=Dockerfile

CMD ["node", "app/launch.js"]
6 changes: 3 additions & 3 deletions app/config/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export declare type Config = {

const DEFAULT_CONFIG: Config = {
port: 3000,
prune: 1000 * 60 * 30,
prune: 1000 * 60 * 60 * 24 * 14,
maxIterations: 20,
maxSchematicSize: 1000 * 1000, // 1 MB
allowedOrigin: '*',
maxSchematicSize: 10240 * 1024, // 10 MiB
limiter: {
windowMs: 1000 * 60,
delayAfter: 30,
Expand All @@ -46,4 +46,4 @@ export const loadConfig = (file: PathLike): Config => {
} catch (error) {
throw error
}
}
}
3 changes: 2 additions & 1 deletion app/http/ArkitektonikaServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class ArkitektonikaServer {
next();
});
this.app.use(this.logger.getExpressLogger());
this.app.set('trust proxy', 1);

INDEX_ROUTER(app, this.app)
UPLOAD_ROUTER(app, this.app)
Expand All @@ -34,4 +35,4 @@ export default class ArkitektonikaServer {
});
}

}
}
2 changes: 1 addition & 1 deletion endpoints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info:
description: Collection of all available endpoints and their responses
version: 1.0.0
basePath: '/'
host: 'api.schematic.cloud'
host: 'api.schematic/cloud'
paths:
/upload:
post:
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,9 @@
"@types/node": "24.12.2",
"@types/pako": "2.0.4",
"nodemon": "3.1.14"
},
"resolutions": {
"@types/express": "4.17.21",
"@types/express-serve-static-core": "4.17.43"
}
}
Loading
Loading