Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create a docker image #84

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 49 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

name: CI

jobs:
jobs:
lints:
name: Check and lints
runs-on: ubuntu-latest
Expand All @@ -30,9 +30,9 @@ jobs:
run: pip3 install git+https://github.com/Scony/godot-gdscript-toolkit.git
- name: Check format GDScript
run: gdformat -d godot/
# Depedencies section
# => Linux

# Dependencies section
# => Linux
- name: Install alsa and udev
if: runner.os == 'linux'
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libasound2-dev libudev-dev
Expand All @@ -55,7 +55,7 @@ jobs:
- name: cargo clippy
working-directory: rust/decentraland-godot-lib
run: cargo clippy -- -D warnings


coverage:
name: Coverage
Expand All @@ -65,7 +65,7 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
Expand All @@ -88,8 +88,8 @@ jobs:
key: coverage-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: coverage-cargo-

# Depedencies section
# => Linux
# Dependencies section
# => Linux
- name: Install alsa and udev
if: runner.os == 'linux'
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libasound2-dev libudev-dev
Expand All @@ -105,7 +105,7 @@ jobs:
run: cargo run -- install --no-templates

# Build section

- name: Download grcov
run: |
mkdir -p "${HOME}/.local/bin"
Expand All @@ -124,7 +124,7 @@ jobs:
build:
name: Build and test
# Comment next line to test this job on PRs
if: ${{ github.ref == 'refs/heads/main' }}
# if: ${{ github.ref == 'refs/heads/main' }}
strategy:
matrix:
os: [self-hosted-windows, ubuntu-latest, macos-latest]
Expand All @@ -136,7 +136,7 @@ jobs:
profile: minimal
toolchain: 1.71
override: true

- name: Set up cargo cache
uses: actions/cache@v3
with:
Expand All @@ -151,9 +151,9 @@ jobs:
rust/xtask/Cargo.lock
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
# Depedencies section
# => Linux

# Dependencies section
# => Linux
- name: Install alsa and udev
if: runner.os == 'linux'
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libasound2-dev libudev-dev
Expand All @@ -164,19 +164,19 @@ jobs:
run: sudo apt update -y; sudo apt install -y libssl-dev libx11-dev libgl1-mesa-dev libxext-dev
if: runner.os == 'linux'

# => MacOS
# => MacOS
- name: install ffmpeg deps (macOs)
if: runner.os == 'macos'
run: brew install ffmpeg pkg-config
# TODO: cross-build deprecated with the ffmpeg integration

# TODO: cross-build deprecated with the ffmpeg integration
# - name: Set up target platform
# if: ${{ matrix.os == 'macos-latest' }}
# run: |
# rustup target add x86_64-apple-darwin
# rustup target add aarch64-apple-darwin


# => Windows
- name: set CLANG path for ffmpeg deps (windows)
if: runner.os == 'windows' && matrix.os != 'self-hosted-windows'
Expand All @@ -199,16 +199,16 @@ jobs:
- name: cargo build
working-directory: rust/decentraland-godot-lib
run: cargo build --release
# TODO: cross-build deprecated with the ffmpeg integration

# TODO: cross-build deprecated with the ffmpeg integration

# - uses: actions-rs/cargo@v1
# name: build for x86_64 (macos)
# if: ${{ matrix.os == 'macos-latest' }}
# with:
# command: build
# args: --manifest-path rust/decentraland-godot-lib/Cargo.toml --release --target=x86_64-apple-darwin

# - uses: actions-rs/cargo@v1
# name: build for arm64 (macos)
# if: ${{ matrix.os == 'macos-latest' }}
Expand All @@ -220,7 +220,7 @@ jobs:
working-directory: rust/decentraland-godot-lib
run: cargo test --release

# TODO: cross-build deprecated with the ffmpeg integration
# TODO: cross-build deprecated with the ffmpeg integration
# Package section
# # => MacOS
# - name: Make universal library
Expand Down Expand Up @@ -253,3 +253,30 @@ jobs:
name: decentraland-godot-${{ matrix.os }}
path: |
exports/**/*

- name: Build Docker Image
if: matrix.os == 'ubuntu-latest'
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: godot-explorer
tags: ${{ github.sha }} ${{ inputs.docker-tag }}
dockerfiles: |
./Dockerfile
build-args: |
${{ inputs.build-args }}
COMMIT_HASH=${{ github.sha }}

- name: Push To quay.io
if: matrix.os == 'ubuntu-latest'
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: quay.io/decentraland
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}

- name: Print image url
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM ubuntu:latest as builder

RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y --no-install-recommends unzip

WORKDIR /app

COPY decentraland-godot-ubuntu-latest.zip /app
RUN unzip decentraland-godot-ubuntu-latest.zip && chmod +x decentraland.godot.client.x86_64

FROM ubuntu:latest

RUN apt-get update && apt-get upgrade -y

RUN apt-get install -y --no-install-recommends \
xvfb libasound2-dev libudev-dev \
clang curl pkg-config libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libavdevice-dev \
libssl-dev libx11-dev libgl1-mesa-dev libxext-dev

WORKDIR /app

COPY --from=builder /app/decentraland.godot.client.x86_64 /app/decentraland.godot.client.pck /app/libdecentraland_godot_lib.so /app/
COPY avatars.json /app/

RUN <<EOF
echo "#!/bin/sh" > entry-point.sh
echo "" >> entry-point.sh
echo "/usr/bin/Xvfb -ac :99 -screen 0 1280x1024x24 &" >> entry-point.sh
echo "export DISPLAY=:99" >> entry-point.sh
echo "./decentraland.godot.client.x86_64 --rendering-driver opengl3 --avatar-renderer --avatars avatars.json" >> entry-point.sh
EOF

RUN chmod +x entry-point.sh

ENTRYPOINT ["./entry-point.sh"]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

2. Go to `rust/xtask` folder, and run `cargo run -- install`.

## Running and editting the project
## Running and editing the project

1. Ensure you are in `rust/xtask` folder first
2. You can run `cargo run -- run` to build the Rust library and execute the client.
Expand All @@ -31,11 +31,11 @@
When GD files are modified, they must be well-formated. You can autoformat all files running `gdformat godot/` (it requires [godot-gdscript-toolkit](https://github.com/Scony/godot-gdscript-toolkit) installed)

## Debugging the library
This repos is set up to be opened with Visual Studio Code. In the section `Run and Debug` in the Activity bar, you can find the configuration for your platform.
This repo is set up to be opened with Visual Studio Code. In the section `Run and Debug` in the Activity bar, you can find the configuration for your platform.

## Run test with coverage
1. Ensure you are in `rust/xtask` folder first
2. Run `cargo run -- coverage --dev`. It'll create a `coverage` folder with the index.html with the all information. For running this commands you need to have lvvm tools and grcov, you can install them with `rustup component add llvm-tools-preview` and `cargo install grcov`.

# Mobile targets
See `rust/decentraland-godot-lib/builds.md`
See `rust/decentraland-godot-lib/builds.md`
7 changes: 4 additions & 3 deletions godot/lib/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Put decentraland_godot_lib libraries files here:
- Windows: decentraland_godot_lib.dll
- MacOS: libdecentraland_godot_lib.dylib
- Linux: libdecentraland_godot_lib.so
- Windows: decentraland_godot_lib.dll
- MacOS: libdecentraland_godot_lib.dylib
- Linux: libdecentraland_godot_lib.so

# Building
First you need to run `cargo build` in `rust/`, then find it on `rust/target/debug`.

Opening with VSCode you can run the task with `Cmd+Shift+P` or `Control+Shift+P`, write `Run task` and look for your platform when writing `Copy GDExtension Lib`.