1
0
Fork 0
mirror of https://github.com/docker/awesome-compose.git synced 2025-04-26 10:43:35 +02:00
awesome-compose/react-express-mysql/backend/Dockerfile
techopsmasters f8fefd6f45
Update Dockerfile
Signed-off-by: techopsmasters <163403479+techopsmasters@users.noreply.github.com>
2024-05-13 19:31:17 +05:30

44 lines
1.4 KiB
Docker
Executable file

# syntax=docker/dockerfile:1.4
# if you're doing anything beyond your local machine, please pin this to a specific version at https://hub.docker.com/_/node/
FROM node:lts AS development
# set our node environment, either development or production
# defaults to production, compose overrides this to development on build and run
ARG NODE_ENV=production
ENV NODE_ENV $NODE_ENV
WORKDIR /code
# default to port 80 for node, and 9229 and 9230 (tests) for debug
ARG PORT=80
ENV PORT $PORT
EXPOSE $PORT 9229 9230
COPY package.json /code/package.json
COPY package-lock.json /code/package-lock.json
RUN npm ci
# check every 30s to ensure this service returns HTTP 200
HEALTHCHECK --interval=30s \
CMD node healthcheck.js
# copy in our source code last, as it changes the most
COPY . /code
# if you want to use npm start instead, then use `docker run --init in production`
# so that signals are passed properly. Note the code in index.js is needed to catch Docker signals
# using node here is still more graceful stopping then npm with --init afaik
# I still can't come up with a good production way to run with npm and graceful shutdown
CMD [ "node", "src/index.js" ]
FROM development as dev-envs
RUN apt update && \
apt install -y --no-install-recommends git
RUN useradd -s /bin/bash -m vscode && \
groupadd docker && \
usermod -aG docker vscode
# install Docker tools (cli, buildx, compose)
COPY --from=gloursdocker/docker / /