Configure Your Go build & deploy pipeline
Zerops provides a customizable build and runtime environment for your Go application.
Add zerops.yml to your repository​
Start by adding zerops.yml
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: go@latest
# OPTIONAL. Set the operating system for the build environment.
# os: ubuntu
# OPTIONAL. Customise the build environment by installing additional packages
# or tools to the base build environment.
# prepareCommands:
# - apt-get something
# - curl something else
# REQUIRED. Build your application
buildCommands:
- go build -o app main.go
# 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: go@latest
# OPTIONAL. Sets the internal port(s) your app listens on:
ports:
# port number
- port: 8080
# OPTIONAL. Customise the runtime Go environment by installing additional
# dependencies to the base Go runtime environment.
# prepareCommands:
# - apt-get 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 Go application is started.
# init:
# - rm -rf ./cache
# REQUIRED. Your Go 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.yml
. This is useful when you use a monorepo. Just add multiple setup elements in your zerops.yml
:
Each service configuration contains at least two sections: build and run. Both sections are required to build and deploy your Go application in Zerops. If you'd like to use a readiness check, add an optional deploy section.