Skip to content
Merged
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
12 changes: 12 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Your numeric uid and gid
HOSTUID=
HOSTGID=

# When run from the root of your project directory, this will be
# the location in the container
WORKSPACE="/workspace"

# Absolute or relative path to your AppImage build script
SCRIPT="$WORKSPACE/path/to/script"

ENTRYPOINT="/entrypoint.sh"
86 changes: 20 additions & 66 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ on:
push:
branches: trunk
paths:
- 'action.yml'
- '.env'
- 'docker-compose.yml'
- '**test.yml'
pull_request:
branches: trunk
paths:
- 'action.yml'
- '.env'
- 'docker-compose.yml'
- '**test.yml'

env:
Expand All @@ -27,8 +29,6 @@ jobs:
platform:
- linux/amd64
- linux/arm64
- linux/arm/v7

steps:
- name: Checkout rmw
uses: actions/checkout@v4
Expand All @@ -44,16 +44,24 @@ jobs:
echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV
fi

- name: Install docker-compose
run: |
#sudo apt update
#sudo apt upgrade -y
sudo apt install -y docker-compose

- name: Checkout rmw
uses: actions/checkout@v4
with:
path: _linuxdeploy_test

- name: Build AppImage
run: |
docker run -t \
--rm \
--platform=${{ matrix.platform }} \
-e HOSTUID=$(id -u) \
-e VERSION \
-v $GITHUB_WORKSPACE:/workspace \
-w /workspace \
andy5995/linuxdeploy:v2-focal packaging/appimage/pre-appimage.sh
export HOSTUID=$(id -u) HOSTGID=$(id -g)
docker-compose -f _linuxdeploy_test/docker-compose.yml run --rm build
env:
SCRIPT: 'packaging/appimage/pre-appimage.sh'
PLATFORM: ${{ matrix.platform }}

- name: Create sha256sum
run: |
Expand All @@ -68,57 +76,3 @@ jobs:
name: ${{ env.IMAGE_FILENAME }}
path: ./out/*
if-no-files-found: error

#test-netpanzer:
#runs-on: ubuntu-latest
#strategy:
#matrix:
#platform: [amd64]
#steps:
#- name: Checkout
#uses: actions/checkout@v4
#- name: Checkout netpanzer
#uses: actions/checkout@v4
#with:
#repository: netpanzer/netpanzer
#path: netpanzer
#- name: Use action from self
#uses: ./
#with:
#platform: ${{ matrix.platform }}
#pre_appimage_script: rmw/packaging/appimage/pre
#sudo apt install -y \
#gettext \
#liblua5.1-0-dev \
#libphysfs-dev \
#libsdl2-dev \
#libsdl2-mixer-dev \
#libsdl2-ttf-dev
#build_commands: |
#git clone --depth 1 https://github.com/netpanzer/netpanzer
#cd netpanzer
#meson setup _build -Dprefix=/usr
#cd _build
#ninja
#install_to_appdir_commands: |
#meson install --destdir=$APPDIR --skip-subprojects
#linuxdeploy_output_version: $VERSION
#linuxdeploy_args: |
#-d netpanzer/support/win32/netpanzer.desktop \
#--custom-apprun=netpanzer/support/appimage/AppRun \
#--icon-file=netpanzer/netpanzer.png \
#--icon-filename=netpanzer \
#--executable $APPDIR/usr/bin/netpanzer \
#--output appimage

#- name: Create sha256sum
#run: |
#cd out
#sha256sum $IMAGE_FILENAME > $IMAGE_FILENAME.sha256sum

#- name: Upload AppImage
#uses: actions/upload-artifact@v4
#with:
#name: ${{ env.IMAGE_FILENAME }}
#path: ./out/*
#if-no-files-found: error
58 changes: 22 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,63 +17,49 @@ version Ubuntu.

(The appimage plugin doesn't yet support 'ppc64le' or 's390x')

## Example usage
## Usage

docker run -t \
--rm \
-e HOSTUID=$(id -u) \
-e VERSION=test \
-v $PWD:/workspace \
-w /workspace \
andy5995/linuxdeploy:v2-focal packaging/appimage/pre-appimage.sh
Make a `docker` sub-directory within your project and copy `.env` and
`docker-compose.yml` to it. Add custom variables to suit your needs. Add your
numeric user and group id to the corresponding variables in `.env`. You can
find them by using:

id -u
id -g

To build the AppImage:

docker-compose -f docker/docker-compose.yml --rm build

This is meant to be run from the source root of your project. Using the
command above, your current directory will be mounted in the container at
`/workspace`.

You can see an example of an AppImage build script at
[rmw/packaging/appimage/pre-appimage.sh](https://github.com/theimpossibleastronaut/rmw/blob/master/packaging/appimage/pre-appimage.sh).
Add the `/path/to/script` in your custom `.env` file.

When the container starts, 'root' changes the UID of user 'builder' (a user
created during the build of the Dockerfile) to HOSTUID. This allows builder to
build your project and create the AppImage without root privileges (the
resulting files will be owned by you).

The only argument given after the name of the docker image in the `docker run`
command is the path/name of the script that builds your projects and includes
the command to call linuxdeploy. You can see an example at
[rmw/packaging/appimage/pre-appimage.sh](https://github.com/theimpossibleastronaut/rmw/blob/master/packaging/appimage/pre-appimage.sh).

You may use `sudo` in your script to install packages or do other things.

If you would like to look around the container, you can use

docker run -it --rm --entrypoint sh andy5995/linuxdeploy:v2-focal
docker run -it --rm --entrypoint bash andy5995/linuxdeploy:v2-focal

## Locally

If you want to clean your project build directory, you can add `-e
CLEAN_BUILD=true` to the `docker run` arguments, and use something like this
in your script:

```sh
# Clean build directory if specified and it exists
if [ "$CLEAN_BUILD" = "true" ] && [ -d "$BUILD_DIR" ]; then
rm -rf "$BUILD_DIR"
fi

# Setup project for building, run ./configure, ./autogen.sh, cmake, etc
if [ ! -d "$BUILD_DIR" ]; then
meson setup "$BUILD_DIR" \
-Dbuildtype=release \
-Dstrip=true \
-Db_sanitize=none \
-Dprefix=/usr
fi
```

To build for other architectures, you may need to use qemu with docker. There
may be other ways, but you can check out [this
document](https://www.stereolabs.com/docs/docker/building-arm-container-on-x86)
for starters. If you are set up to build on other architectures, add
`--platform=linux/<arch>` to the `docker run` arguments.
for starters. If you are set up to build on other architectures, edit the
**PLATFORM** variable in docker-compose.yml, or export it when running
`docker-compose`:

PLATFORM=linux/arm64 docker-compose ...

## In a GitHub Runner

Expand Down
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
build:
environment:
HOSTUID: ${HOSTUID}
HOSTGID: ${HOSTGID}
VERSION: ${VERSION}
image: andy5995/linuxdeploy:v2-focal
platform: ${PLATFORM:-linux/amd64}
entrypoint: $ENTRYPOINT
volumes:
- $PWD:$WORKSPACE
working_dir: $WORKSPACE
command: $SCRIPT
restart: "no"
1 change: 1 addition & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ if [ -z "$1" ]; then
fi

usermod -u "$HOSTUID" builder
groupmod -g "$HOSTGID" builder
chown -R "$HOSTUID:$HOSTGID" /home/builder

# The docs state to use '-w /workdir when running the container, but switching
Expand Down