mirror of
https://github.com/PretendoNetwork/miiverse-api.git
synced 2026-07-18 16:41:25 -05:00
chore: update Docker setup
This commit is contained in:
parent
c81d3b863e
commit
c8a8bd5778
|
|
@ -1,5 +1,5 @@
|
|||
node_modules
|
||||
.git
|
||||
config.json
|
||||
certs
|
||||
src/logs
|
||||
.git
|
||||
.env
|
||||
node_modules
|
||||
dist
|
||||
logs
|
||||
|
|
|
|||
62
Dockerfile
62
Dockerfile
|
|
@ -1,15 +1,47 @@
|
|||
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
|
||||
|
||||
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 && 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,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
files='config.json certs/access/private.pem certs/access/aes.key'
|
||||
|
||||
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
|
||||
|
||||
exec node src/server.js
|
||||
Loading…
Reference in New Issue
Block a user