Skip to content

Commit

Permalink
feat: docker image (#86)
Browse files Browse the repository at this point in the history
* feat: create a docker image

* test

* fix

* fix

* wip

* wip

* wip

* wip

* restore strategy and main branch

---------

Signed-off-by: Lean Mendoza <leandro@decentraland.org>
Co-authored-by: Lean Mendoza <leandro@decentraland.org>
  • Loading branch information
marianogoldman and leanmendoza authored Jan 10, 2024
1 parent 91e3345 commit 75dd06e
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 24 deletions.
64 changes: 46 additions & 18 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 @@ -32,7 +32,7 @@ jobs:
run: gdformat -d godot/
- name: GDScript Linter
run: gdlint godot/
# Depedencies section
# Dependencies section
# => Linux
- name: Install alsa and udev
if: runner.os == 'linux'
Expand All @@ -56,7 +56,7 @@ jobs:
- name: cargo clippy
working-directory: rust/decentraland-godot-lib
run: cargo clippy -- -D warnings


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

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
sudo apt-get -y install xvfb
sudo /usr/bin/Xvfb :0 -screen 0 1280x1024x24 &
# Depedencies section
# Dependencies section
# => Linux
- name: Install alsa and udev
if: runner.os == 'linux'
Expand All @@ -111,7 +111,7 @@ jobs:
run: cargo run -- install --no-templates

# Build section

- name: Download grcov
run: |
mkdir -p "${HOME}/.local/bin"
Expand Down Expand Up @@ -141,7 +141,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 @@ -153,7 +153,7 @@ jobs:
profile: minimal
toolchain: 1.71
override: true

- name: Set up cargo cache
uses: actions/cache@v3
with:
Expand All @@ -168,9 +168,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 @@ -181,19 +181,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 @@ -216,16 +216,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 @@ -236,6 +236,7 @@ jobs:
- name: cargo test
working-directory: rust/decentraland-godot-lib
run: cargo test --release -- --skip auth

# TODO: cross-build deprecated with the ffmpeg integration
# Package section
# # => MacOS
Expand Down Expand Up @@ -269,3 +270,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 }}"
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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 exports/decentraland.godot.client.x86_64 \
exports/decentraland.godot.client.pck \
exports/libdecentraland_godot_lib.so \
entry-point.sh \
/app/

RUN chmod +x entry-point.sh

ENTRYPOINT ["./entry-point.sh"]
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,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 @@ -33,7 +33,7 @@
More details on [CONTRIBUTING.md](CONTRIBUTING.md)

## 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
Expand All @@ -42,6 +42,5 @@ This repos is set up to be opened with Visual Studio Code. In the section `Run a
# Mobile targets
See `rust/decentraland-godot-lib/builds.md`


Powered by the Decentraland DAO
![Decentraland DAO logo](https://bafkreibci6gg3wbjvxzlqpuh353upzrssalqqoddb6c4rez33bcagqsc2a.ipfs.nftstorage.link/)
5 changes: 5 additions & 0 deletions entry-point.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

/usr/bin/Xvfb -ac :99 -screen 0 1280x1024x24 &
export DISPLAY=:99
./decentraland.godot.client.x86_64 --rendering-driver opengl3 --avatar-renderer --avatars avatars.json
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`.

0 comments on commit 75dd06e

Please sign in to comment.