Skip to content

Commit

Permalink
Merge pull request #265 from FraunhoferISST/ci/remove-sponge-from-bas…
Browse files Browse the repository at this point in the history
…e-image

ci(frontend/Dockerfile): removed sponge from base image
  • Loading branch information
tom-rm-meyer-ISST authored Feb 23, 2024
2 parents d3b3165 + 5bc492f commit f110640
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
4 changes: 0 additions & 4 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ FROM node:lts-alpine as build
ARG NPM_BUILD_MODE=dockerbuild
ENV JQ_VERSION=1.6

# TODO curl results in problem with node during ```npm run ${NPM_BUILD_MODE}```
#RUN apk --no-cache add curl
#RUN curl https://github.com/stedolan/jq/releases/download/jq-${JQ_VERSION}/jq-linux64 -o /tmp/jq-linux64
RUN wget --no-check-certificate https://github.com/stedolan/jq/releases/download/jq-${JQ_VERSION}/jq-linux64 -O /tmp/jq-linux64
RUN cp /tmp/jq-linux64 /usr/bin/jq
RUN chmod +x /usr/bin/jq
Expand Down Expand Up @@ -59,7 +56,6 @@ USER root
COPY ./nginx.conf /etc/nginx/nginx.conf
RUN chmod 777 /etc/nginx/nginx.conf
COPY ./start-nginx.sh /usr/bin/start-nginx.sh
RUN apk --no-cache add moreutils

# use non-root user
USER 101
Expand Down
44 changes: 37 additions & 7 deletions frontend/start-nginx.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
#
# Copyright (c) 2023,2024 Volkswagen AG
# Copyright (c) 2023,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

#!/usr/bin/env sh

#
Expand Down Expand Up @@ -30,16 +49,27 @@ echo "==============="

for file in $JSFOLDER;
do
echo -e "\r\n"
echo $file
echo "Substitute environment variables in $file"

tmp_file="$file.tmp"
echo "envsubstitute $file to $tmp_file"
envsubst $EXISTING_VARS < $file > $tmp_file

echo "replace file ($file) by tmp file ($tmp_file)"
rm $file
mv $tmp_file $file

# other command cuts off length of files. sponge has no file-size limitation.
#cat $file | envsubst $EXISTING_VARS | tee $file
#envsubst $EXISTING_VARS < $file | tee $file
envsubst $EXISTING_VARS < $file | sponge $file
echo -e "\r\n"
done

envsubst $EXISTING_VARS < /etc/nginx/nginx.conf | sponge /etc/nginx/nginx.conf
nginx_conf="/etc/nginx/nginx.conf"
tmp_nginx_conf="$nginx_conf.tmp"

echo "envsubstitute $nginx_conf to $tmp_file"
envsubst $EXISTING_VARS < $nginx_conf > $tmp_nginx_conf

echo "replace config ($nginx_conf) by tmp file ($tmp_nginx_conf)"
rm $nginx_conf
mv $tmp_nginx_conf $nginx_conf

nginx -g 'daemon off;'

0 comments on commit f110640

Please sign in to comment.