File: Dockerfile.runtime

package info (click to toggle)
js8call 2.5.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,720 kB
  • sloc: cpp: 562,655; sh: 898; python: 132; ansic: 102; makefile: 4
file content (164 lines) | stat: -rw-r--r-- 8,050 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Runtime container for JS8Call with X11 and audio support
FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive

# Install runtime dependencies
RUN apt-get update && apt-get install -y \
    # X11 support
    x11-apps \
    x11-utils \
    libx11-6 \
    libxext6 \
    libxrender1 \
    libxtst6 \
    libxi6 \
    libxrandr2 \
    libxcursor1 \
    libxinerama1 \
    libxkbcommon-x11-0 \
    # Qt6 runtime dependencies
    qt6-base-dev \
    libqt6core6 \
    libqt6gui6 \
    libqt6widgets6 \
    libqt6multimedia6 \
    libqt6serialport6 \
    libqt6svg6 \
    libqt6opengl6 \
    # Audio support (PulseAudio and ALSA)
    pulseaudio \
    pulseaudio-utils \
    alsa-utils \
    libasound2t64 \
    libpulse0 \
    # Other runtime dependencies
    libfftw3-single3 \
    libusb-1.0-0 \
    libudev1 \
    libboost-filesystem1.83.0 \
    libboost-thread1.83.0 \
    libboost-system1.83.0 \
    # Utilities
    wget \
    ca-certificates \
    file \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user for running the application
# Try to use UID 1000 for PulseAudio compatibility, but use next available if taken
RUN if ! id -u 1000 >/dev/null 2>&1; then \
        useradd -m -s /bin/bash -u 1000 js8call; \
    else \
        useradd -m -s /bin/bash js8call; \
    fi && \
    mkdir -p /home/js8call/.config && \
    chown -R js8call:js8call /home/js8call && \
    usermod -a -G audio,video js8call

# Create config directory
RUN mkdir -p /home/js8call/.config && \
    chown -R js8call:js8call /home/js8call/.config

# Create directory for the extracted application
RUN mkdir -p /opt/js8call && \
    chown js8call:js8call /opt/js8call

# Set up environment for Qt and audio
ENV QT_X11_NO_MITSHM=1
ENV ALSA_CARD=0

# Create entrypoint script
RUN echo '#!/bin/bash' > /opt/js8call/entrypoint.sh && \
    echo 'set -e' >> /opt/js8call/entrypoint.sh && \
    echo '' >> /opt/js8call/entrypoint.sh && \
    echo '# Check if AppImage exists' >> /opt/js8call/entrypoint.sh && \
    echo 'if [ ! -f /tmp/js8call.AppImage ]; then' >> /opt/js8call/entrypoint.sh && \
    echo '    echo "Error: JS8Call AppImage not found at /tmp/js8call.AppImage"' >> /opt/js8call/entrypoint.sh && \
    echo '    echo "Please mount the AppImage to the container"' >> /opt/js8call/entrypoint.sh && \
    echo '    exit 1' >> /opt/js8call/entrypoint.sh && \
    echo 'fi' >> /opt/js8call/entrypoint.sh && \
    echo '' >> /opt/js8call/entrypoint.sh && \
    echo '# Check if we need to extract' >> /opt/js8call/entrypoint.sh && \
    echo 'if [ ! -f /opt/js8call/extracted/AppRun ] && [ ! -f /opt/js8call/extracted/js8call ]; then' >> /opt/js8call/entrypoint.sh && \
    echo '    echo "Extracting AppImage..."' >> /opt/js8call/entrypoint.sh && \
    echo '    cd /opt/js8call' >> /opt/js8call/entrypoint.sh && \
    echo '    # Make AppImage executable first' >> /opt/js8call/entrypoint.sh && \
    echo '    cp /tmp/js8call.AppImage /tmp/js8call-exec.AppImage' >> /opt/js8call/entrypoint.sh && \
    echo '    chmod +x /tmp/js8call-exec.AppImage' >> /opt/js8call/entrypoint.sh && \
    echo '    # Extract the AppImage' >> /opt/js8call/entrypoint.sh && \
    echo '    /tmp/js8call-exec.AppImage --appimage-extract > /dev/null 2>&1 || {' >> /opt/js8call/entrypoint.sh && \
    echo '        echo "Standard extraction failed, trying manual extraction..."' >> /opt/js8call/entrypoint.sh && \
    echo '        mkdir -p /opt/js8call/extracted' >> /opt/js8call/entrypoint.sh && \
    echo '        cd /opt/js8call/extracted' >> /opt/js8call/entrypoint.sh && \
    echo '        unsquashfs -f -d . /tmp/js8call-exec.AppImage || {' >> /opt/js8call/entrypoint.sh && \
    echo '            echo "Failed to extract AppImage"' >> /opt/js8call/entrypoint.sh && \
    echo '            exit 1' >> /opt/js8call/entrypoint.sh && \
    echo '        }' >> /opt/js8call/entrypoint.sh && \
    echo '    }' >> /opt/js8call/entrypoint.sh && \
    echo '    # Move extracted contents if needed' >> /opt/js8call/entrypoint.sh && \
    echo '    if [ -d /opt/js8call/squashfs-root ]; then' >> /opt/js8call/entrypoint.sh && \
    echo '        mv /opt/js8call/squashfs-root /opt/js8call/extracted' >> /opt/js8call/entrypoint.sh && \
    echo '    fi' >> /opt/js8call/entrypoint.sh && \
    echo '    rm -f /tmp/js8call-exec.AppImage' >> /opt/js8call/entrypoint.sh && \
    echo 'fi' >> /opt/js8call/entrypoint.sh && \
    echo '' >> /opt/js8call/entrypoint.sh && \
    echo '# Find the executable' >> /opt/js8call/entrypoint.sh && \
    echo 'if [ -f /opt/js8call/extracted/AppRun ]; then' >> /opt/js8call/entrypoint.sh && \
    echo '    EXEC_PATH="/opt/js8call/extracted/AppRun"' >> /opt/js8call/entrypoint.sh && \
    echo 'elif [ -f /opt/js8call/extracted/js8call ]; then' >> /opt/js8call/entrypoint.sh && \
    echo '    EXEC_PATH="/opt/js8call/extracted/js8call"' >> /opt/js8call/entrypoint.sh && \
    echo 'elif [ -f /opt/js8call/extracted/usr/bin/js8call ]; then' >> /opt/js8call/entrypoint.sh && \
    echo '    EXEC_PATH="/opt/js8call/extracted/usr/bin/js8call"' >> /opt/js8call/entrypoint.sh && \
    echo 'else' >> /opt/js8call/entrypoint.sh && \
    echo '    EXEC_PATH=$(find /opt/js8call/extracted -name "js8call" -type f -executable | head -1)' >> /opt/js8call/entrypoint.sh && \
    echo '    if [ -z "$EXEC_PATH" ]; then' >> /opt/js8call/entrypoint.sh && \
    echo '        echo "Could not find js8call executable in extracted AppImage"' >> /opt/js8call/entrypoint.sh && \
    echo '        ls -la /opt/js8call/extracted/' >> /opt/js8call/entrypoint.sh && \
    echo '        exit 1' >> /opt/js8call/entrypoint.sh && \
    echo '    fi' >> /opt/js8call/entrypoint.sh && \
    echo 'fi' >> /opt/js8call/entrypoint.sh && \
    echo '' >> /opt/js8call/entrypoint.sh && \
    echo '# Copy existing config if mounted' >> /opt/js8call/entrypoint.sh && \
    echo 'if [ -d /tmp/js8call-config ] && [ -f /tmp/js8call-config/JS8Call.ini ]; then' >> /opt/js8call/entrypoint.sh && \
    echo '    echo "Loading existing configuration..."' >> /opt/js8call/entrypoint.sh && \
    echo '    mkdir -p /home/js8call/.config' >> /opt/js8call/entrypoint.sh && \
    echo '    cp /tmp/js8call-config/JS8Call.ini /home/js8call/.config/JS8Call.ini' >> /opt/js8call/entrypoint.sh && \
    echo 'fi' >> /opt/js8call/entrypoint.sh && \
    echo '' >> /opt/js8call/entrypoint.sh && \
    echo '# Launch JS8Call from extracted directory' >> /opt/js8call/entrypoint.sh && \
    echo 'echo "Starting JS8Call from $EXEC_PATH..."' >> /opt/js8call/entrypoint.sh && \
    echo 'cd /opt/js8call/extracted' >> /opt/js8call/entrypoint.sh && \
    echo '"$EXEC_PATH" "$@"' >> /opt/js8call/entrypoint.sh && \
    echo 'EXIT_CODE=$?' >> /opt/js8call/entrypoint.sh && \
    echo '' >> /opt/js8call/entrypoint.sh && \
    echo '# Copy config file back if mounted' >> /opt/js8call/entrypoint.sh && \
    echo 'if [ -d /tmp/js8call-config ]; then' >> /opt/js8call/entrypoint.sh && \
    echo '    if [ -f /home/js8call/.config/JS8Call.ini ]; then' >> /opt/js8call/entrypoint.sh && \
    echo '        echo "Saving configuration..."' >> /opt/js8call/entrypoint.sh && \
    echo '        cp /home/js8call/.config/JS8Call.ini /tmp/js8call-config/JS8Call.ini' >> /opt/js8call/entrypoint.sh && \
    echo '    fi' >> /opt/js8call/entrypoint.sh && \
    echo 'fi' >> /opt/js8call/entrypoint.sh && \
    echo '' >> /opt/js8call/entrypoint.sh && \
    echo 'exit $EXIT_CODE' >> /opt/js8call/entrypoint.sh

RUN chmod +x /opt/js8call/entrypoint.sh && \
    chown js8call:js8call /opt/js8call/entrypoint.sh

# Install squashfs-tools for extraction
RUN apt-get update && apt-get install -y squashfs-tools && rm -rf /var/lib/apt/lists/*

# Make sure js8call user can access X11
RUN mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix

# Make home directory writable by any user
RUN chmod -R 777 /home/js8call && \
    mkdir -p /home/js8call/.local/share && \
    chmod -R 777 /home/js8call/.local

# Switch to non-root user
USER js8call
WORKDIR /home/js8call

# Default command
CMD ["/opt/js8call/entrypoint.sh"]