From dcf6e565c2d04b9857a53723186437dce4c0b037 Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Mon, 28 Aug 2023 12:34:48 +0400 Subject: [PATCH] Multi-stage build, compose yml --- Dockerfile | 18 +++++++----------- README.md | 4 ++-- docker-compose.yml | 12 ++++++++++++ 3 files changed, 21 insertions(+), 13 deletions(-) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index a29838d..c8553a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,12 @@ -FROM node:18-alpine - +FROM node:18-alpine as build WORKDIR /app - -COPY package*.json . - -RUN npm install - COPY . . - +RUN npm install RUN npm run build -ENV PORT=8080 +FROM node:18-alpine as run +WORKDIR /app +COPY /app/dist /app/package*.json . --from=build +RUN npm install --omit=dev +CMD npm start EXPOSE 8080 - -CMD ["npm", "start"] diff --git a/README.md b/README.md index 3c089a6..8e397aa 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,6 @@ npm run start ### Docker ```bash -sudo docker build -t txtdot/txtdot:latest . -sudo docker run --network host -d txtdot/txtdot:latest +docker compose build +docker compose up -d ``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..44a7b43 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3" + +services: + txtdot: + image: darkcat09/txtdot:latest + restart: unless-stopped + network_mode: host + environment: + - HOST=127.0.0.1 + - PORT=8080 + - REVERSE_PROXY=true + # env_file: .env