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

Update to Support zwo files better and other Minor Fixes. #150

Merged
merged 10 commits into from
Jul 14, 2024
18 changes: 10 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ ARG WINE_VERSION="=9.9~trixie-1"

ARG WINETRICKS_VERSION=20240105
ARG DEBIAN_VERSION
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=all
ENV WINEDEBUG=fixme-all

RUN dpkg --add-architecture i386

Expand Down Expand Up @@ -72,6 +69,11 @@ RUN adduser --disabled-password --gecos '' user && \

FROM wine-base

# Moved Environments into wine-base build part.
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=all
ENV WINEDEBUG=fixme-all

LABEL org.opencontainers.image.authors="Kim Eik <[email protected]>"
LABEL org.opencontainers.image.title="netbrain/zwift"
LABEL org.opencontainers.image.description="Easily zwift on linux"
Expand All @@ -82,19 +84,19 @@ RUN apt-get update && \
rm -rf /var/lib/apt/lists/*

COPY entrypoint.sh /bin/entrypoint
RUN chmod +x /bin/entrypoint
RUN chmod +rx /bin/entrypoint

COPY update_zwift.sh /bin/update_zwift.sh
RUN chmod +x /bin/update_zwift.sh
RUN chmod +rx /bin/update_zwift.sh

COPY run_zwift.sh /bin/run_zwift.sh
RUN chmod +x /bin/run_zwift.sh
RUN chmod +rx /bin/run_zwift.sh

COPY zwift-auth.sh /bin/zwift-auth
RUN chmod +x /bin/zwift-auth
RUN chmod +rx /bin/zwift-auth

COPY --from=build-runfromprocess /usr/src/target/x86_64-pc-windows-gnu/release/runfromprocess-rs.exe /bin/runfromprocess-rs.exe
RUN chmod +x /bin/runfromprocess-rs.exe
RUN chmod +rx /bin/runfromprocess-rs.exe

ENTRYPOINT ["entrypoint"]
CMD [$@]
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ If you find this image useful, then feel free add [me on zwift](https://www.zwif

## Prerequisites
- [Docker](https://docs.docker.com/get-docker) or [Podman](https://podman.io/getting-started/installation)
- [nvidia-container-toolkit](https://github.com/NVIDIA/nvidia-docker) if you have nvidia proprietary driver
- [nvidia-container-toolkit](https://github.com/NVIDIA/nvidia-container-toolkit) if you have nvidia proprietary driver
- ATI, Intel and Nouveau drivers should work out of the box

> :warning: **Podman Support 4.3 and Later.**: Podman before 4.3 does not support --userns=keep-id:uid=xxx,gid=xxx and will not start correctly, this impacts Ubuntu 22.04 and related builds such as PopOS 22.04. See Podman Section below.
Expand Down Expand Up @@ -49,6 +49,7 @@ If dbus is available through a unix socket, the screensaver will be inhibited ev
| CONTAINER_TOOL | | Defaults to podman if installed, else docker |
| ZWIFT_USERNAME | | If set, try to login to zwift automatically |
| ZWIFT_PASSWORD | | " |
| ZWIFT_WORKOUT_DIR | | Set the workouts directory location |
| WINE_EXPERIMENTAL_WAYLAND| | If set, try to use experimental wayland support in wine 9 |
| NETWORKING | bridge | Sets the type of container networking to use. |
| ZWIFT_UID | current users id | Sets the UID that Zwift will run as (docker only) |
Expand Down Expand Up @@ -89,6 +90,16 @@ Note: This will be loaded by zwift.sh in cleartext as environment variables into

> :warning: **Do Not Quote the variables or add spaces**: The ID and Password are read as raw format so if you put ZWIFT_PASSWORD="password" it tries to use "password" and not just password, same for ''. In addition do not add a space to the end of the line it will be sent as part of the pasword or username. This applies to ZWIFT_USERNAME and ZWIFT_PASSWORD.

NOTE: You can also add other environment variable from the table to make starting easier:
```
ZWIFT_USERNAME=username
ZWIFT_PASSWORD=password

ZWIFT_WORKOUT_DIR=~/.config/zwift/workouts
WINE_EXPERIMENTAL_WAYLAND=1
```


## Podman Support

When running Zwift with podman, the user and group in the container is 1000 (user). To access the resources on the host we need to map the container id's 1000 to the host id's using uidmap and gidmap.
Expand Down Expand Up @@ -128,31 +139,20 @@ For example, your Wahoo Kickr and Apple Watch conect to the Zwift Companion app
iPhone; then the Companion app connects over wifi to your PC running Zwift.

## How can I add custom .zwo files?
You can map the Zwift Workout folder using the environment variable ZWIFT_WORKOUT_DIR, for example if your workout directory is in $HOME/zwift_workouts then you would provide the environment variable

The folder's name that receives .zwo files is dynamic based on your user's numeric ID. This example works considering you have a single user in the same docker volume.
After you've downloaded/created your .zwo files use the following script to copy it to the correct folder:

```console
# docker
docker run -v zwift-$USER:/data --name zwift-copy-op busybox ls /data/Workouts | xargs -I {} docker cp my-workouts-file.zwo zwift-copy-op:/data/Workouts/{}
docker rm zwift-copy-op
```ZWIFT_WORKOUT_DIR=$HOME/zwift_workouts```

#podman
@TBD
```
You can add this variable into $HOME/.config/zwift/config or $HOME/.config/zwift/$USER-config.

If you have multiple users at the same volume you might want to find out which IDs exist in your setup and map the ID for each user to copy correctly to the corresponding user.
An example of this would be:
The workouts folder will contain subvolders e.g. $HOME/.config/zwift/workouts/393938. The number is your internal zwift id and you store you zwo files in the relevant folder. There will usually be only one ID, however if you have multiple zwift login's it may show one subfolder for each, to find the ID you can use the following link:

```console
# docker
docker run -v zwift-$USER:/data --name zwift-copy-op busybox true
docker cp my-workouts-file.zwo zwift-copy-op:/data/Workouts/1234
docker rm zwift-copy-op
Webpage for finding internal ID: https://www.virtualonlinecycling.com/p/zwiftid.html

#podman
@TBD
```
NOTES:
- Any workouts created already will be copied into this folder on first start
- To add a new workout just copy the zwo file to this directory
- Deleting files from the directory will not delete them, they will be re-added when re-starting zwift, you must delete from the zwift menu

## How can I build the image myself?

Expand Down
5 changes: 3 additions & 2 deletions bin/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ else
fi

# Initiate podman Volume with correct permissions
if [[ "$CONTAINER_TOOL" == "podman" ]]
then
if [[ "$CONTAINER_TOOL" == "podman" ]]; then
# Add ipc host to deal with an SHM issue on some machines.
PODMAN_FLAGS=(
--userns keep-id:uid=$ZWIFT_UID,gid=$ZWIFT_GID
--ipc host
)
fi

Expand Down
9 changes: 7 additions & 2 deletions zwift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ msgbox() {
# More ease of use starting from desktop icon.

# Check for other zwift configuration, sourced here and passed on to container aswell
if [[ -f "$HOME/.config/zwift/config" ]]
then
if [[ -f "$HOME/.config/zwift/config" ]]; then
ZWIFT_CONFIG_FLAG="--env-file $HOME/.config/zwift/config"
source $HOME/.config/zwift/config
fi
Expand All @@ -54,6 +53,11 @@ then
source $HOME/.config/zwift/$USER-config
fi

# If a workout directory is specified then map to that directory.
if [[ ! -z $ZWIFT_WORKOUT_DIR ]]; then
ZWIFT_WORKOUT_VOL="-v $ZWIFT_WORKOUT_DIR:/home/user/.wine/drive_c/users/user/Documents/Zwift/Workouts"
fi

########################################
###### Default Setup and Settings ######
WINDOW_MANAGER="Other" # XOrg, XWayland, Wayland, Other
Expand Down Expand Up @@ -249,6 +253,7 @@ fi
CONTAINER=$($CONTAINER_TOOL run ${GENERAL_FLAGS[@]} \
$ZWIFT_CONFIG_FLAG \
$ZWIFT_USER_CONFIG_FLAG \
$ZWIFT_WORKOUT_VOL \
$VGA_DEVICE_FLAG \
${DBUS_CONFIG_FLAGS[@]} \
${WM_FLAGS[@]} \
Expand Down