mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 16:55:37 +02:00
✨ feat: Add a separate image to build warp (#23)
## Description **What(what issue does this code solve/what feature does it add):** Build times for netris:server are way too long. so the idea is to move warp into it's own container then build from there. Later on first release we might drop this for a better solution. **How(how does it solve it):** 1. Added the very own netris:warp ## Required Checklist: - [x] I have added any necessary documentation and comments in my code (where appropriate) - [x] I have added tests to make sure my code runs in all contexts ## Further comments
This commit is contained in:
51
.github/workflows/server.yml
vendored
51
.github/workflows/server.yml
vendored
@@ -31,63 +31,14 @@ concurrency:
|
|||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-cargo:
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: moq-server
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- name: Install Rust
|
|
||||||
id: toolchain
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
with:
|
|
||||||
targets: x86_64-unknown-linux-gnu
|
|
||||||
toolchain: stable
|
|
||||||
components: clippy, rustfmt
|
|
||||||
|
|
||||||
- name: Cache Rust Dependencies
|
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
save-if: false
|
|
||||||
prefix-key: 'v0-rust-deps'
|
|
||||||
shared-key: x86_64-unknown-linux-gnu
|
|
||||||
|
|
||||||
- name: Cargo build
|
|
||||||
run: cargo build --target x86_64-unknown-linux-gnu --manifest-path ./moq-pub/Cargo.toml --release
|
|
||||||
|
|
||||||
- name: Copy and rename artifacts (Linux)
|
|
||||||
run: |
|
|
||||||
cp target/x86_64-unknown-linux-gnu/release/moq-pub ./warp
|
|
||||||
|
|
||||||
- name: Publish artifacts
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: warp
|
|
||||||
path: ./moq-server/warp
|
|
||||||
if-no-files-found: error
|
|
||||||
retention-days: 5
|
|
||||||
|
|
||||||
build-docker-pr:
|
build-docker-pr:
|
||||||
name: Build image on pr
|
name: Build image on pr
|
||||||
needs:
|
|
||||||
- build-cargo
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout repo
|
name: Checkout repo
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
-
|
|
||||||
name: Download go binary
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: warp
|
|
||||||
path: ./
|
|
||||||
-
|
-
|
||||||
name: Setup Docker Buildx
|
name: Setup Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -105,8 +56,6 @@ jobs:
|
|||||||
name: Build image on merge to main
|
name: Build image on merge to main
|
||||||
if: ${{github.ref == 'refs/heads/main'}}
|
if: ${{github.ref == 'refs/heads/main'}}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
|
||||||
- build-cargo
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
|||||||
166
.github/workflows/warp.yml
vendored
166
.github/workflows/warp.yml
vendored
@@ -1,19 +1,108 @@
|
|||||||
name: CI for moq-rs
|
#Tabs not spaces, you moron :)
|
||||||
|
|
||||||
|
name: CI for netris:warp
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
pull_request:
|
||||||
schedule:
|
paths:
|
||||||
- cron: 0 0 * * * # At the end of everyday
|
- "warp.Dockerfile"
|
||||||
pull_request: #TODO: run only on dependabot updates
|
- ".github/workflows/warp.yml"
|
||||||
release:
|
schedule:
|
||||||
types: [published]
|
- cron: 0 0 * * * # At the end of everyday
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
paths:
|
||||||
|
- "warp.Dockerfile"
|
||||||
|
- ".github/workflows/warp.yml"
|
||||||
|
tags:
|
||||||
|
- v*.*.*
|
||||||
|
release:
|
||||||
|
types: [published, created]
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: wanjohiryan/netris
|
||||||
|
BASE_TAG_PREFIX: warp
|
||||||
|
|
||||||
# Cancel previous runs of the same workflow on the same branch.
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
build-docker-pr:
|
||||||
|
name: Build image on pr
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
-
|
||||||
|
name: Setup Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
-
|
||||||
|
name: Build Docker image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
file: warp.Dockerfile
|
||||||
|
context: ./
|
||||||
|
push: false
|
||||||
|
load: true
|
||||||
|
tags: netris:warp
|
||||||
|
|
||||||
|
build-docker-main:
|
||||||
|
name: Build image on merge to main
|
||||||
|
if: ${{github.ref == 'refs/heads/main'}}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
-
|
||||||
|
name: Download warp
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: warp
|
||||||
|
path: ./
|
||||||
|
-
|
||||||
|
name: Log into registry ${{ env.REGISTRY }}
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
-
|
||||||
|
name: Extract Container metadata
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ env.BASE_TAG_PREFIX }}
|
||||||
|
#
|
||||||
|
#tag on release, and a nightly build for 'dev'
|
||||||
|
tags: |
|
||||||
|
type=raw,value=nightly,enable={{is_default_branch}}
|
||||||
|
type=ref,event=tag
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
-
|
||||||
|
name: Build Docker image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
file: warp.Dockerfile
|
||||||
|
context: ./
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
build-warp-release:
|
build-warp-release:
|
||||||
if: ${{ github.event_name == 'release' }}
|
if: ${{ github.event_name == 'release' }}
|
||||||
defaults:
|
defaults:
|
||||||
@@ -59,7 +148,7 @@ jobs:
|
|||||||
id: toolchain
|
id: toolchain
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
with:
|
||||||
targets: x86_64-unknown-linux-gnu
|
targets: ${{ matrix.settings.target }}
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
components: clippy, rustfmt
|
components: clippy, rustfmt
|
||||||
|
|
||||||
@@ -68,25 +157,25 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
save-if: false
|
save-if: false
|
||||||
prefix-key: 'v0-rust-deps'
|
prefix-key: 'v0-rust-deps'
|
||||||
shared-key: x86_64-unknown-linux-gnu
|
shared-key: ${{ matrix.settings.target }}
|
||||||
|
|
||||||
- name: Cargo build
|
- name: Cargo build
|
||||||
run: cargo build --target x86_64-unknown-linux-gnu --manifest-path ./moq-pub/Cargo.toml --release
|
run: cargo build --target ${{ matrix.settings.target }} --manifest-path ./moq-pub/Cargo.toml --release
|
||||||
|
|
||||||
- name: Copy and rename artifacts (Linux)
|
- name: Copy and rename artifacts (Linux)
|
||||||
if: ${{ matrix.settings.host == 'ubuntu-20.04' }}
|
if: ${{ matrix.settings.host == 'ubuntu-20.04' }}
|
||||||
run: |
|
run: |
|
||||||
cp target/x86_64-unknown-linux-gnu/release/moq-pub ./warp
|
cp target/${{ matrix.settings.target }}/release/moq-pub ./warp
|
||||||
|
|
||||||
- name: Copy and rename artifacts (Windows)
|
- name: Copy and rename artifacts (Windows)
|
||||||
if: ${{ matrix.settings.host == 'windows-latest' }}
|
if: ${{ matrix.settings.host == 'windows-latest' }}
|
||||||
run: |
|
run: |
|
||||||
cp "target/x86_64-unknown-linux-gnu/release/moq-pub.exe" ./warp.exe
|
cp "target/${{ matrix.settings.target }}/release/moq-pub.exe" ./warp.exe
|
||||||
|
|
||||||
- name: Copy and rename artifacts (macOS)
|
- name: Copy and rename artifacts (macOS)
|
||||||
if: ${{ matrix.settings.host == 'macos-latest' }}
|
if: ${{ matrix.settings.host == 'macos-latest' }}
|
||||||
run: |
|
run: |
|
||||||
cp target/x86_64-unknown-linux-gnu/release/moq-pub ./warp
|
cp target/${{ matrix.settings.target }}/release/moq-pub ./warp
|
||||||
|
|
||||||
- name: Publish release for (${{ matrix.settings.host }})
|
- name: Publish release for (${{ matrix.settings.host }})
|
||||||
if: ${{ matrix.settings.host == 'windows-latest' }}
|
if: ${{ matrix.settings.host == 'windows-latest' }}
|
||||||
@@ -104,47 +193,4 @@ jobs:
|
|||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: ./moq-server/warp
|
file: ./moq-server/warp
|
||||||
asset_name: ${{ matrix.settings.asset_name }}
|
asset_name: ${{ matrix.settings.asset_name }}
|
||||||
tag: ${{ github.ref }}
|
tag: ${{ github.ref }}
|
||||||
|
|
||||||
build-warp-pr:
|
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
|
||||||
name: Build warp on PR
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: moq-server
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- name: Install Rust
|
|
||||||
id: toolchain
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
with:
|
|
||||||
targets: x86_64-unknown-linux-gnu
|
|
||||||
toolchain: stable
|
|
||||||
components: clippy, rustfmt
|
|
||||||
|
|
||||||
- name: Cache Rust Dependencies
|
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
save-if: false
|
|
||||||
prefix-key: 'v0-rust-deps'
|
|
||||||
shared-key: x86_64-unknown-linux-gnu
|
|
||||||
|
|
||||||
- name: Cargo build
|
|
||||||
run: cargo build --target x86_64-unknown-linux-gnu --manifest-path ./moq-pub/Cargo.toml --release
|
|
||||||
|
|
||||||
- name: Copy and rename artifacts (Linux)
|
|
||||||
run: |
|
|
||||||
cp target/x86_64-unknown-linux-gnu/release/moq-pub ./warp
|
|
||||||
|
|
||||||
- name: Publish artifacts
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: warp-ubuntu-amd64
|
|
||||||
path: ./moq-server/warp
|
|
||||||
if-no-files-found: error
|
|
||||||
retention-days: 5
|
|
||||||
@@ -40,8 +40,8 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
|
|||||||
&& chown $USERNAME:$USERNAME /home/$USERNAME \
|
&& chown $USERNAME:$USERNAME /home/$USERNAME \
|
||||||
&& ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
|
&& ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
|
||||||
|
|
||||||
COPY warp /usr/bin/netris/
|
# COPY warp /usr/bin/netris/
|
||||||
RUN chmod +x /usr/bin/netris/warp
|
# RUN chmod +x /usr/bin/netris/warp
|
||||||
COPY .scripts/entrypoint.sh .scripts/supervisord.conf /etc/
|
COPY .scripts/entrypoint.sh .scripts/supervisord.conf /etc/
|
||||||
RUN chmod 755 /etc/supervisord.conf /etc/entrypoint.sh
|
RUN chmod 755 /etc/supervisord.conf /etc/entrypoint.sh
|
||||||
|
|
||||||
|
|||||||
13
warp.Dockerfile
Normal file
13
warp.Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
FROM rust:bookworm as builder
|
||||||
|
|
||||||
|
# Create a build directory and copy over all of the files
|
||||||
|
WORKDIR /build
|
||||||
|
COPY ./moq-server/ ./
|
||||||
|
# Reuse a cache between builds.
|
||||||
|
# I tried to `cargo install`, but it doesn't seem to work with workspaces.
|
||||||
|
# There's also issues with the cache mount since it builds into /usr/local/cargo/bin
|
||||||
|
# We can't mount that without clobbering cargo itself.
|
||||||
|
# We instead we build the binaries and copy them to the cargo bin directory.
|
||||||
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||||
|
--mount=type=cache,target=/build/target \
|
||||||
|
cargo build --manifest-path ./moq-pub/Cargo.toml --target x86_64-unknown-linux-gnu --release && cp target/x86_64-unknown-linux-gnu/release/moq-pub /usr/bin/warp
|
||||||
Reference in New Issue
Block a user