mirror of
https://github.com/PretendoNetwork/account.git
synced 2026-04-26 00:06:14 -05:00
chore: update Dockerfile for production use
This uses a standard Node.js Dockerfile template and removes the old, unused entrypoint script.
This commit is contained in:
parent
7e2b47ce75
commit
41977cf7af
|
|
@ -1,6 +1,4 @@
|
|||
.git
|
||||
config.json
|
||||
logs
|
||||
certs
|
||||
cdn
|
||||
node_modules
|
||||
.git
|
||||
node_modules
|
||||
dist
|
||||
logs
|
||||
|
|
|
|||
64
Dockerfile
64
Dockerfile
|
|
@ -1,16 +1,48 @@
|
|||
FROM node:18-alpine
|
||||
|
||||
RUN apk add --no-cache python3 make gcc g++
|
||||
WORKDIR /app
|
||||
|
||||
COPY "docker/entrypoint.sh" ./
|
||||
|
||||
COPY package*.json ./
|
||||
RUN npm install bcrypt && npm rebuild bcrypt --build-from-source
|
||||
RUN npm install
|
||||
|
||||
COPY . ./
|
||||
|
||||
VOLUME [ "/app/config.json", "/app/certs" ]
|
||||
|
||||
CMD ["sh", "entrypoint.sh"]
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG app_dir="/home/node/app"
|
||||
|
||||
|
||||
# * Base Node.js image
|
||||
FROM node:20-alpine AS base
|
||||
ARG app_dir
|
||||
WORKDIR ${app_dir}
|
||||
|
||||
|
||||
# * 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 base 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
|
||||
ARG app_dir
|
||||
|
||||
RUN mkdir -p ${app_dir}/logs
|
||||
RUN chown node:node ${app_dir}/logs
|
||||
|
||||
ENV NODE_ENV production
|
||||
USER node
|
||||
|
||||
COPY package.json .
|
||||
|
||||
COPY --from=dependencies ${app_dir}/node_modules ${app_dir}/node_modules
|
||||
COPY --from=build ${app_dir}/dist ${app_dir}/dist
|
||||
|
||||
CMD ["node", "."]
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# this doesnt check game server specific certs, only static file paths
|
||||
files='config.json'
|
||||
|
||||
for file in $files; do
|
||||
if [ ! -f $file ]; then
|
||||
echo "$PWD/$file file does not exist. Please mount and try again."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# check for keys
|
||||
keys='certs/nex/datastore/secret.key certs/service/account/secret.key certs/service/account/aes.key certs/service/account/private.pem certs/service/account/public.pem'
|
||||
for file in $keys; do
|
||||
if [ ! -f "$file" ]; then
|
||||
if [ x"${GENERATE_NEW_KEYS}" = "x" ]; then
|
||||
echo "$PWD/$file file does not exist. Please mount and try again."
|
||||
exit 1
|
||||
else
|
||||
echo "$PWD/$file file does not exist. Generating a temporary one"
|
||||
node generate-keys.js nex datastore
|
||||
node generate-keys.js account
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
exec node src/server.js
|
||||
Loading…
Reference in New Issue
Block a user