chore: the Docker build time errors have been fixed by changing the name of the nginx folder and renaming build.sh to prepare.sh

This commit is contained in:
Junior L. Botelho (JLB) 2023-02-11 16:53:22 -03:00
parent 9abb2cdbc8
commit 450560eb6d
No known key found for this signature in database
GPG Key ID: 6A25840754F2A524
4 changed files with 16 additions and 13 deletions

View File

@ -8,9 +8,9 @@ export DOCKER_BUILDKIT=1
# These templates will be used to create configuration files that incorporate values from environment variables
# If these locations do not already exist within the Docker container, they will be created
export CONFIG_PHP_TEMPLATE="$(pwd)/templates/config.php"
export CONFIG_NGINX_TEMPLATE="$(pwd)/templates/nginx.conf"
export CONFIG_OPEN_SEARCH_TEMPLATE="$(pwd)/templates/opensearch.xml"
export CONFIG_PHP_TEMPLATE="$(pwd)/scripts/tmp/config.php"
export CONFIG_NGINX_TEMPLATE="$(pwd)/scripts/tmp/nginx.conf"
export CONFIG_OPEN_SEARCH_TEMPLATE="$(pwd)/scripts/tmp/opensearch.xml"
# Configure 'opensearch.xml' with Librex configuration metadata, such as the encoding and the host that stores the site
# These configurations will replace the 'opensearch.xml' inside '.dockers/templates' for the best setup for your instance
@ -58,11 +58,11 @@ export CURLOPT_MAXREDIRS=${CURLOPT_MAXREDIRS:-5}
export CURLOPT_TIMEOUT=${CURLOPT_TIMEOUT:-18}
export CURLOPT_VERBOSE=${CURLOPT_VERBOSE:-false}
# These shell functions will be available for use by any function calls
function AwkTrim() { awk '{$1=$1};1'; }
# The lines below will replace the environment variables in the templates with the corresponding variables listed above. To accomplish this, the GNU 'envsubst' package will be used
# Although not recommended (if you do not know what you are doing), you still have the option to add new substitution file templates using any required environment variables
[[ ! -s ${CONFIG_PHP_TEMPLATE} ]] && cat '$(pwd)/config.php' | envsubst | AwkTrim > ${CONFIG_PHP_TEMPLATE}
[[ ! -s ${CONFIG_NGINX_TEMPLATE} ]] && cat '$(pwd)/nginx.conf' | envsubst | AwkTrim > ${CONFIG_NGINX_TEMPLATE}
[[ ! -s ${CONFIG_OPEN_SEARCH_TEMPLATE} ]] && cat '$(pwd)/opensearch.xml' | envsubst | AwkTrim > ${CONFIG_OPEN_SEARCH_TEMPLATE}
# These shell functions will be available for use by any function calls
function AwkTrim() { awk '{$1=$1};1' }
[[ ! -s ${CONFIG_PHP_TEMPLATE} ]] && cat 'scripts/config.php' | envsubst | AwkTrim > ${CONFIG_PHP_TEMPLATE};
[[ ! -s ${CONFIG_NGINX_TEMPLATE} ]] && cat 'scripts/nginx.conf' | envsubst | AwkTrim > ${CONFIG_NGINX_TEMPLATE};
[[ ! -s ${CONFIG_OPEN_SEARCH_TEMPLATE} ]] && cat 'scripts/opensearch.xml' | envsubst | AwkTrim > ${CONFIG_OPEN_SEARCH_TEMPLATE};

View File

@ -73,17 +73,20 @@ ADD "." "."
# Set permissions for script files as executable scripts inside 'docker/scripts' directory
RUN chmod u+x "scripts/entrypoint.sh" &&\
chmod u+x "scripts/build.sh"
chmod u+x "scripts/prepare.sh"
# Add 'zip' package to generate a temporary compressed 'librex.zip' for best recursive copy between Docker images
# Remove unnecessary folders and create a temporary folder that will contain the zip file created earlier
# Compress Librex files, excluding the '.docker' folder containing scripts and the Dockerfile, using the previously downloaded zip package
# Delete all files in the root directory, except for the '.docker' and 'tmp' folders, which are created exclusively to be handled by Docker
RUN apk update; apk add zip --no-cache &&\
rm -rf .git; mkdir -p "{tmp,templates}/zip" &&\
RUN apk update; apk add zip abuild-rootbld --no-cache &&\
rm -rf .git; mkdir -p "tmp/zip" &&\
zip -r "tmp/zip/librex.zip" . -x "scripts/**\*" "Dockerfile\*" &&\
find -maxdepth 1 ! -name "scripts" ! -name "tmp" ! -name "templates" ! -name "." -exec rm -rv {} \; &&\
apk del -r zip;
sh -c 'scripts/prepare.sh' && apk del -r zip abuild-rootbld
RUN docker build --no-cache -t 'nginx:latest' scripts/nginx/nginx.dockerfile &&\
docker build --no-cache -t 'php:latest' scripts/php/php.dockerfile
# Configures the container to be run as an executable.
ENTRYPOINT ["/bin/sh", "-c", "scripts/entrypoint.sh"]