From 416fbd7990c4d62df95baa96f3cab11096a710d2 Mon Sep 17 00:00:00 2001 From: yun Date: Wed, 22 Nov 2023 11:01:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 5 +++++ Dockerfile | 19 +++++++++++++++++++ docker-compose.yml | 14 ++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..4f75c951 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +node_modules +.git +.gitignore +*.md +dist diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..f9db114a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM node:18-alpine AS base +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +RUN corepack enable +COPY . /app +WORKDIR /app + +FROM base AS prod-deps +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile + +FROM base AS build +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile +RUN pnpm run build + +FROM base +COPY --from=prod-deps /app/node_modules /app/node_modules +COPY --from=build /app/dist /app/dist +EXPOSE 3000 +CMD [ "pnpm", "dev" ] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..8fd70984 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3' + +services: + ray-template: + build: . + container_name: ray-template + restart: unless-stopped + environment: + - TZ=Asia/Shanghai + ports: + - "3000:3000" + # if you want to persist +# volumes: +# - ./app:/app From 3767861fe481240ef3d27c03e285a8ab1a851f2e Mon Sep 17 00:00:00 2001 From: yun Date: Wed, 22 Nov 2023 11:39:16 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddocker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 24 ++++++++---------------- docker-compose.yml | 2 +- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index f9db114a..f9cba20b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,11 @@ -FROM node:18-alpine AS base -ENV PNPM_HOME="/pnpm" -ENV PATH="$PNPM_HOME:$PATH" -RUN corepack enable +FROM debian:11 COPY . /app WORKDIR /app - -FROM base AS prod-deps -RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile - -FROM base AS build -RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile -RUN pnpm run build - -FROM base -COPY --from=prod-deps /app/node_modules /app/node_modules -COPY --from=build /app/dist /app/dist -EXPOSE 3000 +RUN apt-get update +RUN apt-get install -y wget curl make sudo unzip +RUN curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - +RUN apt-get install -y nodejs +RUN npm i -g pnpm +RUN pnpm install +EXPOSE 9527 CMD [ "pnpm", "dev" ] diff --git a/docker-compose.yml b/docker-compose.yml index 8fd70984..8392aeb8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: environment: - TZ=Asia/Shanghai ports: - - "3000:3000" + - "9527:9527" # if you want to persist # volumes: # - ./app:/app