Skip to content

Commit

Permalink
build(docker): update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed May 21, 2024
1 parent 4133202 commit dedadeb
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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
Expand Down

0 comments on commit dedadeb

Please sign in to comment.