Configure Your Alpine build & deploy pipeline
Zerops provides a customizable build and runtime environment for your Alpine application.
Add zerops.yaml to your repository
Start by adding zerops.yaml file to the root of your repository and modify it to fit your application:
zerops:
# define hostname of your service
- setup: app
# ==== how to build your application ====
build:
# REQUIRED. Set the base technology for the build environment:
base: alpine@3.20
# OPTIONAL. Customize the build environment by installing additional packages
# or tools to the base build environment.
prepareCommands:
- sudo apk add --no-cache something
- curl something else
# OPTIONAL. Build your application
buildCommands:
- <your build commands>
# REQUIRED. Select which files / folders to deploy after
# the build has successfully finished
deployFiles: app
# OPTIONAL. Which files / folders you want to cache for the next build.
# Next builds will be faster when the cache is used.
cache: some_file
# ==== how to run your application ====
run:
# OPTIONAL. Sets the base technology for the runtime environment:
base: alpine@3.20
# OPTIONAL. Sets the internal port(s) your app listens on:
ports:
# port number
- port: 8080
# OPTIONAL. Customize the runtime Alpine environment by installing additional
# dependencies to the base Alpine runtime environment.
prepareCommands:
- sudo apk add --no-cache something
- curl something else
# OPTIONAL. Run one or more commands each time a new runtime container
# is started or restarted. These commands are triggered before
# your Alpine application is started.
initCommands:
- rm -rf ./cache
# OPTIONAL. Your Alpine application start command
start: ./app
The top-level element is always zerops.
Setup
The first element setup contains the hostname of your service. A runtime service with the same hostname must exist in Zerops.
Zerops supports the definition of multiple runtime services in a single zerops.yaml. This is useful when you use a monorepo. Just add multiple setup elements in your zerops.yaml:
Each service configuration contains at least the run section. Optional build and deploy sections can be added to further customize your process.
Build pipeline configuration
base
REQUIRED. Sets the base technology for the build environment.
Following options are available for Alpine builds:
alpine@3.20,alpine@latestalpine@3.19alpine@3.18alpine@3.17
The base build environment contains Alpine 3.20, Zerops command line tool, git and wget.
You can change the base environment when you need to. Just simply modify the zerops.yaml in your repository.
If you need to install more technologies to the build environment, set multiple values as a yaml array. For example:
See the full list of supported build base environments.
To customize your build environment use the prepareCommands attribute.
Modifying the base technology will invalidate your build cache. See our Build Cache Documentation for more details about cache invalidation.
prepareCommands
OPTIONAL. Customizes the build environment by installing additional dependencies or tools to the base build environment.
The base build environment contains:
- Alpine 3.20
- Zerops command line tool
gitandwget
To install additional packages or tools add one or more prepare commands:
zerops:
# hostname of your service
- setup: app
# ==== how to build your application ====
build:
# REQUIRED. Set the base technology for the build environment:
base: alpine@3.20
# OPTIONAL. Customize the build environment by installing additional packages
# or tools to the base build environment.
prepareCommands:
- sudo apk add --no-cache something
- curl something else
...
When the first build is triggered, Zerops will
- create a build container
- download your application code from your repository
- run the prepare commands in the defined order
The application code is available in the /var/www folder in your build container before the prepare commands are triggered. This allows you to use any file from your application code in your prepare commands (e.g. a configuration file).
These commands are skipped when using cached environment. Modifying prepareCommands will invalidate your build cache. See our Build Cache Documentation for details about cache invalidation.
Command exit code
If any command fails, it returns an exit code other than 0 and the build is canceled. Read the build log to troubleshoot the error. If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all prepare commands are finished, your custom build environment is ready for the build phase.
Single or separated shell instances
You can configure your prepare commands to be run in a single shell instance or multiple shell instances. The format is identical to build commands.
buildCommands
OPTIONAL. Defines build commands.
Build commands are optional. Zerops triggers each command in the defined order in a dedicated build container.
Before the build commands are triggered the build container contains:
- base environment defined by the base attribute
- optional customisation of the base environment defined in the prepareCommands attribute
- your application code
For detailed information about build commands, refer to the documentation for your specific technology (e.g., Node.js, Go, Python, etc.).
Run build commands as a single shell instance
Use following syntax to run all commands in the same environment context. For example, if one command changes the current directory, the next command continues in that directory. When one command creates an environment variable, the next command can access it.
Run build commands as separate shell instances
When the following syntax is used, each command is triggered in a separate environment context. For example, each shell instance starts in the home directory again. When one command creates an environment variable, it won't be available for the next command.
Command exit code
If any command fails, it returns an exit code other than 0 and the build is canceled. Read the build log to troubleshoot the error.
If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all buildCommands are finished, the application build is completed and ready for the deploy phase.
deployFiles
REQUIRED. Selects which files or folders will be deployed after the build has successfully finished. To filter out specific files or folders, use .deployignore file.
Determines files or folders produced by your build, which should be deployed to your runtime service containers.
The path starts from the root directory of your project (the location of zerops.yaml). You must enclose the name in quotes if the folder or the file name contains a space.
The files/folders will be placed into /var/www folder in runtime, e.g. ./src/assets/fonts would result in /var/www/src/assets/fonts.
Examples
Deploys a folder, and a file from the project root directory:
Deploys the whole content of the build container:
Deploys a folder, and a file in a defined path: