mirror of
https://github.com/sp-tarkov/build.git
synced 2025-02-13 06:30:45 -05:00
Refringe
816f791eeb
- Removes git directory from container - Changes all projects to build within a `build` directory - Adds a combine_builds script that takes the individual project builds and merges them into an `output` directory - Adds placeholder tag_validate script - Validates MODULE_DOMAIN env variable - Updates the Launcher project build to use the `dotnet build` command - Pins the `dotnet build` command to one thread to prevent Avalonia file access errors on build: https://github.com/AvaloniaUI/Avalonia/pull/13840 - Bleeding edge builds are now built as such. TODO: - Add additional static project files - Compress output directory - Upload release to public folder - Adapt to work within Drone env - Adapt build script to work with a dynamic tag value - Only run project builds when the tag exists in all three projects
87 lines
4.6 KiB
Markdown
87 lines
4.6 KiB
Markdown
# 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:
|
|
|
|
1. Checks if the passed in tag exists in all three project repositories.
|
|
1. Clones the tagged commits of each repository.
|
|
1. Builds each project.
|
|
1. Combines and compresses the build files into a release file.
|
|
1. Copies the release file to a web-accessible location.
|
|
1. 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:
|
|
|
|
1. Open `Windows Server Manager`
|
|
1. Select `Manage`
|
|
1. Select `Add Roles and Features`
|
|
1. Click `Next` on the `Before You Begin` page
|
|
1. Select `Role-based or feature-based installation`
|
|
1. Select the name of the server where the feature will be installed and click `Next`
|
|
1. Select `Hyper-V` and click `Next`
|
|
1. Select `Containers` and click `Next`
|
|
1. Click `Install` on the `Confirm installation selections` page
|
|
1. Click `Close` on the `Installation progress` page
|
|
1. Open a PowerShell terminal (as admin) and run the following commands to install Docker CE:
|
|
|
|
```powershell
|
|
# 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.
|
|
|
|
```powershell
|
|
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.
|
|
|
|
```powershell
|
|
# 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 container
|
|
docker build -t spt-build-environment .
|
|
|
|
# Run the build script
|
|
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
|
|
```
|