Got to a point where the server and modules are being compiled correctly. Launcher script needs... something. It's failing to build and I don't know why. TODO: - Fix Launcher Build Script - Combine sub-builds into output directory - Compress output directory - Upload release to public folder - Adapt build script to work with a dynamic tag value - Update script to only run _any_ builds when the tag exists in all three - Write drone configuration version of the dockerfile/script - Testing within the Drone env
SPT Build Project - CI/CD Process
This document outlines the Continuous Integration and Continuous Deployment (CI/CD) setup for the SPT-AKI/Build
project, which automates the build and release process for three interconnected repositories: SPT-AKI/Modules
, SPT-AKI/Server
, and SPT-AKI/Launcher
. The process is orchestrated using Drone CI with Gitea and relies on a Windows Docker runner to execute PowerShell scripts for building and packaging the projects.
Project Repositories
Each of the three project repositories (SPT-AKI/Modules
, SPT-AKI/Server
, SPT-AKI/Launcher
) requires a .drone.yml
file configured to trigger a build in this SPT-AKI/Build
repository using the Drone downstream plugin upon a new tag push (e.g., v3.8.0
). The contents of the .drone.yml
file can be found in project-trigger.yml
. Note that the file must be present and named .drone.yml
to trigger the build process.
Build Process
This repository's .drone.yml
initiates the CI/CD process by running a PowerShell script build.ps1
on a Windows Docker runner. The PowerShell script performs the following actions:
- Checks if the passed in tag exists in all three project repositories.
- Clones the tagged commits of each repository.
- Builds each project.
- Combines and compresses the build files into a release file.
- Copies the release file to a web-accessible location.
- Release notifications (creates a Gitea release, sends a Discord notification, etc.)
Drone Runner Configuration
Drone CI Runner Requirements:
- Windows Server 2022 Host
- Docker Community Edition (CE)
Install Docker CE
Docker CE needs to be installed (not Docker Desktop). The following steps outline the installation process for Windows Server 2022:
To install Docker CE on Windows Server 2022, follow these steps:
- Open
Windows Server Manager
- Select
Manage
- Select
Add Roles and Features
- Click
Next
on theBefore You Begin
page - Select
Role-based or feature-based installation
- Select the name of the server where the feature will be installed and click
Next
- Select
Hyper-V
and clickNext
- Select
Containers
and clickNext
- Click
Install
on theConfirm installation selections
page - Click
Close
on theInstallation progress
page - Open a PowerShell terminal (as admin) and run the following commands to install Docker CE:
# Download install script
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1" -o install-docker-ce.ps1
# Run install script
.\install-docker-ce.ps1
# Test Docker installation
Get-Service Docker
Run the Runner
Use the command below to start the Drone CI Runner. But first...
- Replace the
DRONE_RPC_HOST
value with the host of the Drone server that should be connected to for builds. - Replace the
DRONE_RPC_SECRET
value with the Drone server secret. - Replace the
DRONE_RUNNER_NAME
value with a unique name for the runner. - Replace the
DRONE_UI_PASSWORD
value with a password to access the web runner UI. - Adjust
DRONE_RUNNER_CAPACITY
to the number of builds that should be allowed to run at once.
docker run --detach --volume=//./pipe/docker_engine://./pipe/docker_engine --env=DRONE_RPC_PROTO=https --env=DRONE_RPC_HOST=example.com --env=DRONE_RPC_SECRET=secret --env=DRONE_RUNNER_CAPACITY=2 --env=DRONE_RUNNER_NAME=example --env=DRONE_UI_DISABLE=false --env=DRONE_UI_USERNAME=root --env=DRONE_UI_PASSWORD=password --publish=3000:3000 --restart=always --name=runner drone/drone-runner-docker:latest
Module Requirements
To build the Modules project, a link to a private repository is required for the build process. The link is stored as a secret in the Drone CI/CD environment. The secret is named MODULE_DOMAIN
and is used to download files from the private repository.
Testing Build Process
To test the build process, the following commands can be used to build the Docker image and run the container on the Windows Server 2022 host. Be sure to replace the MODULE_DOMAIN
environment variable with a valid value.
# Clone the repository and move inside the project directory
git clone https://dev.sp-tarkov.com/SPT-AKI/Build.git C:\Code\Build
cd C:\Code\Build
# Build the Docker image
docker build -t spt-build-environment .
# Test the build process
docker run --rm -v "C:\Code\Build:C:\Code" -e MODULE_DOMAIN="https://example.com" spt-build-environment powershell -File C:\Code\project\build.ps1