chore: move the DNS server to a separate container

This commit is contained in:
Matthew Lopez
2024-06-02 15:49:00 -04:00
parent 736ed587d9
commit 8fc66b13aa
8 changed files with 52 additions and 8 deletions

3
dns/.dockerignore Normal file
View File

@@ -0,0 +1,3 @@
.env
node_modules
dist

View File

@@ -1,2 +1,2 @@
dist
*.js
*.js

View File

@@ -51,4 +51,4 @@
"always"
]
}
}
}

42
dns/Dockerfile Normal file
View File

@@ -0,0 +1,42 @@
# syntax=docker/dockerfile:1
# * Base Node.js image
FROM node:20-alpine AS base
WORKDIR /home/node/app
# * Installing production dependencies
FROM base AS dependencies
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci --omit=dev
# * Installing development dependencies and building the application
FROM dependencies AS build
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci
COPY . .
RUN npm run build
# * Running the final application
FROM base AS final
RUN npm install -g pm2
ENV NODE_ENV production
USER node
COPY package.json .
COPY --from=dependencies /home/node/app/node_modules ./node_modules
COPY --from=build /home/node/app/dist ./dist
CMD pm2 start . --no-daemon

View File

@@ -1,12 +1,12 @@
{
"name": "@pretendonetwork/sssl-dns",
"version": "1.0.1",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@pretendonetwork/sssl-dns",
"version": "1.0.1",
"version": "1.0.0",
"license": "AGPL-3.0",
"dependencies": {
"@colors/colors": "^1.6.0",

View File

@@ -5,9 +5,8 @@
"main": "dist/server.js",
"scripts": {
"lint": "npx eslint .",
"build": "npm run lint && npm run clean && npx tsc && npx tsc-alias && npm run copy-files",
"build": "npm run lint && npm run clean && npx tsc && npx tsc-alias",
"clean": "npx rimraf ./dist",
"copy-files": "cp package.json dist/package.json && cp README.md dist/README.md",
"start": "node --enable-source-maps ."
},
"author": "PretendoNetwork",

View File

@@ -144,4 +144,4 @@ server.on('listening', () => {
server.listen({
udp: udpPort !== 0 ? udpPort : undefined,
tcp: tcpPort !== 0 ? tcpPort : undefined
});
});

View File

@@ -18,4 +18,4 @@
}
},
"include": ["src"]
}
}