2024-05-03 12:56:44 -07:00
|
|
|
FROM node:20
|
|
|
|
|
2024-05-12 22:06:11 -07:00
|
|
|
# Security: Drop all capabilities
|
|
|
|
USER root
|
|
|
|
RUN apt-get update && apt-get install -y libcap2-bin
|
|
|
|
RUN setcap cap_net_bind_service=+ep /usr/local/bin/node
|
|
|
|
|
2024-05-03 12:56:44 -07:00
|
|
|
WORKDIR /code
|
|
|
|
|
|
|
|
COPY package*.json ./
|
|
|
|
|
|
|
|
RUN npm install
|
|
|
|
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
RUN npm run build
|
|
|
|
|
2024-05-12 22:06:11 -07:00
|
|
|
# Security: Create non-root user and assign ownership
|
|
|
|
RUN useradd -m myuser
|
|
|
|
RUN mkdir projects && chown -R myuser:myuser projects
|
|
|
|
USER myuser
|
|
|
|
|
2024-05-21 00:57:52 -07:00
|
|
|
# user namespace mapping
|
|
|
|
|
2024-05-03 12:56:44 -07:00
|
|
|
EXPOSE 3000
|
2024-05-17 22:23:44 -07:00
|
|
|
EXPOSE 4000
|
2024-05-03 12:56:44 -07:00
|
|
|
|
|
|
|
CMD [ "node", "dist/index.js" ]
|