From dedadeb2a511171cfd7be417cf851824127ddabc Mon Sep 17 00:00:00 2001 From: Alex Layton Date: Mon, 20 May 2024 23:31:40 -0400 Subject: [PATCH] build(docker): update Dockerfile --- Dockerfile | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6ddb8d6..364f8a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,43 @@ +# Copyright 2022 Qlever LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + ARG NODE_VER=20-alpine -ARG SERVICE=trellisfw/monitor +ARG DIR=/usr/src/app/ FROM node:$NODE_VER AS install -ARG SERVICE +ARG DIR -WORKDIR /$SERVICE +WORKDIR ${DIR} -COPY ./.yarn /$SERVICE/.yarn -COPY ./package.json ./yarn.lock ./.yarnrc.yml /$SERVICE/ +COPY ./.yarn ${DIR}.yarn +COPY ./package.json ./yarn.lock ./.yarnrc.yml ${DIR} RUN yarn workspaces focus --all --production FROM install AS build -ARG SERVICE +ARG DIR # Install dev deps too RUN yarn install --immutable -COPY . /$SERVICE/ +COPY . ${DIR} # Build code and remove dev deps RUN yarn build --verbose && rm -rfv .yarn .pnp* FROM node:$NODE_VER AS production -ARG SERVICE +ARG DIR # Install needed packages RUN apk add --no-cache \ @@ -32,10 +46,10 @@ RUN apk add --no-cache \ # Do not run service as root USER node -WORKDIR /$SERVICE +WORKDIR ${DIR} -COPY --from=install /$SERVICE/ /$SERVICE/ -COPY --from=build /$SERVICE/ /$SERVICE/ +COPY --from=install ${DIR} ${DIR} +COPY --from=build ${DIR} ${DIR} # Launch entrypoint with dumb-init # Remap SIGTERM to SIGINT https://github.com/Yelp/dumb-init#signal-rewriting