-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build): add full dockerfile containing yarn step
We can create images without yarn installed and this change streamlines dockerfiles across portal repositories. Refs: #186
- Loading branch information
1 parent
d91cecc
commit fad4f08
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
############################################################### | ||
# Copyright (c) 2022 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License, Version 2.0 which is available at | ||
# https://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. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
############################################################### | ||
|
||
# Step 1 | ||
FROM node:21-alpine as build-step | ||
ARG http_proxy=$http_proxy | ||
ARG https_proxy=$https_proxy | ||
ARG no_proxy=$no_proxy | ||
RUN apk update && apk add --no-cache jq | ||
COPY . /app | ||
WORKDIR /app | ||
RUN yarn | ||
RUN yarn build | ||
|
||
# Step 2 | ||
FROM nginxinc/nginx-unprivileged:alpine | ||
COPY .conf/nginx.conf /etc/nginx/conf.d/default.conf | ||
COPY --from=build-step /app/build /usr/share/nginx/html | ||
# Change to root user | ||
USER root | ||
# Rename index.html to index.html.reference, to be used by env variables inject script | ||
RUN mv /usr/share/nginx/html/index.html /usr/share/nginx/html/index.html.reference | ||
# Create symlink for tmp for index.html to enable readOnlyRootFilesystem | ||
RUN ln -s /tmp/index.html /usr/share/nginx/html/index.html | ||
# Add env variables inject script and mark as executable | ||
COPY ./scripts/inject-dynamic-env.sh /docker-entrypoint.d/00-inject-dynamic-env.sh | ||
RUN chmod +x /docker-entrypoint.d/00-inject-dynamic-env.sh | ||
# Install bash for env variables inject script | ||
RUN apk update && apk add --no-cache bash | ||
# Make nginx owner of /usr/share/nginx/html/ and change to nginx user | ||
RUN chown -R 101:101 /usr/share/nginx/html/ | ||
# Change to nginx user | ||
USER 101 |