This directory contains additional scripts and instructions for building the app image. The process is structured around two key scripts: base.sh, and app.sh, each executed at specific stages of the image build process.
-
base.shLocated in
/tmp/, this script runs commands after the installation of the default system packages. -
app.shFound in
/var/www/html/, this script is the final step and runs commands after the application is fully installed.
Important
Ensure every script starts with the following line:
set -euo pipefail
This enforces:
-e: Immediate exit if a command fails.-u: Treating unset variables as errors.-o pipefail: Exiting if any command in a pipeline fails.
Adhering to this structure keeps the build process modular, clean, and reusable.
Here’s an example workflow for installing bash, nano, and yarn.
-
Updating and Adding Packages in
base.sh:#!/usr/bin/env sh set -euo pipefail apk --no-cache add bash nano yarn
Since
bashis installed, it enables the use of bash scripts for further instructions. -
Running Additional Commands in
app.sh:During application setup (
app.sh), you can execute tasks likeyarn installor other instructions.#!/usr/bin/env bash set -euo pipefail yarn install
Additional scripts can be included to handle specific tasks. For example, to manage PHP extensions, you can create a php_extensions.sh script and link it to base.sh.
-
Modifying
base.shto Callphp_extensions.sh:#!/usr/bin/env sh set -euo pipefail apk --no-cache add bash imagemagick-dev pecl install imagick chmod +x "./php_extensions.sh" ./php_extensions.sh
-
Content of
php_extensions.sh:This script installs PHP extensions like
imagick.#!/usr/bin/env bash set -euo pipefail docker-php-ext-enable imagick
[ back to home ]