2022-10-07 04:23:29 +03:00
|
|
|
#
|
|
|
|
# Copyright (c) Microsoft.
|
|
|
|
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
2022-10-31 06:32:58 +03:00
|
|
|
#
|
2022-10-07 04:23:29 +03:00
|
|
|
|
2023-06-12 03:42:22 +03:00
|
|
|
ARG IMAGE_NAME=mcr.microsoft.com/cbl-mariner/base/nodejs:18
|
2021-03-11 11:29:21 +03:00
|
|
|
|
|
|
|
FROM $IMAGE_NAME AS build
|
2017-09-13 23:21:00 +03:00
|
|
|
|
2019-04-06 00:45:34 +03:00
|
|
|
ARG NPM_TOKEN
|
|
|
|
|
2023-11-14 20:42:30 +03:00
|
|
|
RUN tdnf -y update --quiet
|
|
|
|
|
|
|
|
# We used to also make Git available for NPM and rsync in build
|
|
|
|
# tdnf clean all --quiet && \
|
|
|
|
# tdnf -y install ca-certificates git --quiet && \
|
2019-04-06 00:45:34 +03:00
|
|
|
|
2020-02-07 13:25:49 +03:00
|
|
|
WORKDIR /build
|
2020-04-23 06:39:39 +03:00
|
|
|
|
|
|
|
COPY . .
|
2019-04-06 00:45:34 +03:00
|
|
|
|
2022-10-08 01:25:28 +03:00
|
|
|
# Only if needed, copy file with NPM_TOKEN arg
|
|
|
|
# COPY .npmrc.arg /build/.npmrc
|
2020-06-12 00:46:09 +03:00
|
|
|
|
2022-10-08 01:25:28 +03:00
|
|
|
# RUN npm install --ignore-scripts --production --verbose
|
|
|
|
RUN npm ci
|
2020-02-07 13:25:49 +03:00
|
|
|
RUN npm run-script build
|
2022-10-08 01:25:28 +03:00
|
|
|
RUN mv node_modules production_node_modules
|
|
|
|
RUN rm -f .npmrc
|
2017-09-13 23:21:00 +03:00
|
|
|
|
2020-04-23 08:27:07 +03:00
|
|
|
# The open source project build needs: build the site assets sub-project
|
2022-10-08 01:25:28 +03:00
|
|
|
RUN cd default-assets-package && npm ci && npm run build
|
2019-04-06 00:45:34 +03:00
|
|
|
|
2021-03-11 11:29:21 +03:00
|
|
|
FROM $IMAGE_NAME AS run
|
2019-04-06 00:45:34 +03:00
|
|
|
|
2020-02-07 13:47:22 +03:00
|
|
|
ENV IS_DOCKER=1 \
|
2020-02-07 13:12:27 +03:00
|
|
|
NPM_CONFIG_LOGLEVEL=warn \
|
2020-04-23 06:39:39 +03:00
|
|
|
DEBUG=startup \
|
2020-02-07 13:12:27 +03:00
|
|
|
PORT=3000
|
2019-04-06 00:45:34 +03:00
|
|
|
|
2020-04-23 06:39:39 +03:00
|
|
|
EXPOSE 3000
|
2019-04-06 00:45:34 +03:00
|
|
|
|
|
|
|
WORKDIR /usr/src/repos
|
|
|
|
|
|
|
|
# Production Node.js modules
|
2022-10-07 04:23:29 +03:00
|
|
|
COPY --from=build /build/production_node_modules ./node_modules
|
2017-09-13 23:21:00 +03:00
|
|
|
|
2020-04-23 06:39:39 +03:00
|
|
|
# People not using painless config may need
|
2022-10-07 04:23:29 +03:00
|
|
|
COPY --from=build /build/data ./data
|
2017-09-13 23:21:00 +03:00
|
|
|
|
2019-04-06 00:45:34 +03:00
|
|
|
# Copy built assets, app, config map
|
2022-10-07 04:23:29 +03:00
|
|
|
COPY --from=build /build/dist ./
|
2017-09-13 23:21:00 +03:00
|
|
|
|
2020-04-23 08:27:07 +03:00
|
|
|
# The open source project build needs: default assets should be placed
|
2023-01-07 21:16:27 +03:00
|
|
|
COPY --from=build /build/default-assets-package ./default-assets-package
|
2020-04-23 06:39:39 +03:00
|
|
|
|
2022-10-07 09:08:43 +03:00
|
|
|
COPY --from=build /build/config ./config
|
|
|
|
COPY --from=build /build/views ./views
|
|
|
|
COPY --from=build /build/package.json ./package.json
|
2022-10-07 08:55:02 +03:00
|
|
|
|
2022-10-08 01:25:28 +03:00
|
|
|
# Only if needed, copy our environment
|
2022-10-07 04:23:29 +03:00
|
|
|
# COPY --from=build /build/.environment ./.environment
|
|
|
|
|
2023-12-20 02:57:35 +03:00
|
|
|
# Only if needed, binary resources
|
|
|
|
# COPY --from=build /build/microsoft/assets ./microsoft/assets
|
|
|
|
|
2019-04-06 00:45:34 +03:00
|
|
|
ENTRYPOINT ["npm", "run-script", "start-in-container"]
|