Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(build): add full dockerfile containing yarn step #187

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .conf/Dockerfile.full
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions .conf/Dockerfile → .conf/Dockerfile.prebuilt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .conf/docker-notice-registration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-release_candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down