diff --git a/.conf/Dockerfile.full b/.conf/Dockerfile.full new file mode 100644 index 00000000..e4c6022f --- /dev/null +++ b/.conf/Dockerfile.full @@ -0,0 +1,53 @@ +############################################################### +# Copyright (c) 2024 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 +############################################################### + +# +# Dockerfile with full build after checkout +# + +# 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 diff --git a/.conf/Dockerfile b/.conf/Dockerfile.prebuilt similarity index 97% rename from .conf/Dockerfile rename to .conf/Dockerfile.prebuilt index 41474db2..c0540670 100644 --- a/.conf/Dockerfile +++ b/.conf/Dockerfile.prebuilt @@ -17,6 +17,10 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### +# +# Dockerfile with prebuilt webapp +# + FROM nginxinc/nginx-unprivileged:alpine COPY .conf/nginx.conf /etc/nginx/conf.d/default.conf COPY ./build /usr/share/nginx/html diff --git a/.conf/docker-notice-registration.md b/.conf/docker-notice-registration.md index f0603a59..169fc27b 100644 --- a/.conf/docker-notice-registration.md +++ b/.conf/docker-notice-registration.md @@ -8,7 +8,7 @@ __Portal Frontend Registration__ - GitHub: https://github.com/eclipse-tractusx/portal-frontend-registration - Project home: https://projects.eclipse.org/projects/automotive.tractusx -- Dockerfile: https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/.conf/Dockerfile +- Dockerfile: https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/.conf/Dockerfile.prebuilt - Project license: [Apache License, Version 2.0](https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/LICENSE) __Used base images__ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc405581..8979139f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -87,7 +87,7 @@ jobs: uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 with: context: . - file: .conf/Dockerfile + file: .conf/Dockerfile.prebuilt platforms: linux/amd64, linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/release-release_candidate.yml b/.github/workflows/release-release_candidate.yml index 712681ab..13f075e6 100644 --- a/.github/workflows/release-release_candidate.yml +++ b/.github/workflows/release-release_candidate.yml @@ -111,7 +111,7 @@ jobs: uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 with: context: . - file: .conf/Dockerfile + file: .conf/Dockerfile.prebuilt platforms: linux/amd64, linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 80d2585d..8bab83b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -112,7 +112,7 @@ jobs: uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 with: context: . - file: .conf/Dockerfile + file: .conf/Dockerfile.prebuilt platforms: linux/amd64, linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/release_candidate.yml b/.github/workflows/release_candidate.yml index dcd5e241..273a03dd 100644 --- a/.github/workflows/release_candidate.yml +++ b/.github/workflows/release_candidate.yml @@ -87,7 +87,7 @@ jobs: uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 with: context: . - file: .conf/Dockerfile + file: .conf/Dockerfile.prebuilt platforms: linux/amd64, linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }}