mirror of
https://github.com/woodchen-ink/docker-firefox.git
synced 2025-07-18 13:52:02 +08:00
Adaptations for the new baseimage version 4.
This commit is contained in:
parent
1b36ec0101
commit
32b23d080a
69
Dockerfile
69
Dockerfile
@ -13,20 +13,18 @@ RUN gcc -static -o membarrier_check membarrier_check.c
|
||||
RUN strip membarrier_check
|
||||
|
||||
# Pull base image.
|
||||
FROM jlesage/baseimage-gui:alpine-3.15-v3.5.8
|
||||
FROM jlesage/baseimage-gui:alpine-3.16-v4.0.1
|
||||
|
||||
# Docker image version is provided via build arg.
|
||||
ARG DOCKER_IMAGE_VERSION=unknown
|
||||
ARG DOCKER_IMAGE_VERSION=
|
||||
|
||||
# Define software versions.
|
||||
ARG FIREFOX_VERSION=94.0-r0
|
||||
ARG YAD_VERSION=7.3
|
||||
ARG FIREFOX_VERSION=101.0.1-r0
|
||||
ARG JSONLZ4_VERSION=c4305b8
|
||||
ARG LZ4_VERSION=1.8.1.2
|
||||
#ARG PROFILE_CLEANER_VERSION=2.36
|
||||
|
||||
# Define software download URLs.
|
||||
ARG YAD_URL=https://github.com/v1cont/yad/releases/download/v${YAD_VERSION}/yad-${YAD_VERSION}.tar.xz
|
||||
ARG JSONLZ4_URL=https://github.com/avih/dejsonlz4/archive/${JSONLZ4_VERSION}.tar.gz
|
||||
ARG LZ4_URL=https://github.com/lz4/lz4/archive/v${LZ4_VERSION}.tar.gz
|
||||
#ARG PROFILE_CLEANER_URL=https://github.com/graysky2/profile-cleaner/raw/v${PROFILE_CLEANER_VERSION}/common/profile-cleaner.in
|
||||
@ -64,49 +62,13 @@ RUN \
|
||||
# --upgrade firefox=${FIREFOX_VERSION}
|
||||
add-pkg firefox=${FIREFOX_VERSION}
|
||||
|
||||
# Install YAD.
|
||||
# NOTE: YAD is compiled manually because the version on the Alpine repository
|
||||
# pulls too much dependencies.
|
||||
RUN \
|
||||
# Install packages needed by the build.
|
||||
add-pkg --virtual build-dependencies \
|
||||
build-base \
|
||||
curl \
|
||||
intltool \
|
||||
gtk+3.0-dev \
|
||||
&& \
|
||||
# Set same default compilation flags as abuild.
|
||||
export CFLAGS="-Os -fomit-frame-pointer" && \
|
||||
export CXXFLAGS="$CFLAGS" && \
|
||||
export CPPFLAGS="$CFLAGS" && \
|
||||
export LDFLAGS="-Wl,--as-needed" && \
|
||||
# Download.
|
||||
mkdir yad && \
|
||||
echo "Downloading YAD package..." && \
|
||||
curl -# -L ${YAD_URL} | tar xJ --strip 1 -C yad && \
|
||||
# Compile.
|
||||
cd yad && \
|
||||
./configure \
|
||||
--prefix=/usr \
|
||||
--enable-standalone \
|
||||
--disable-icon-browser \
|
||||
--disable-html \
|
||||
--disable-pfd \
|
||||
&& \
|
||||
make && make install && \
|
||||
strip /usr/bin/yad && \
|
||||
cd .. && \
|
||||
# Cleanup.
|
||||
del-pkg build-dependencies && \
|
||||
rm -rf /tmp/* /tmp/.[!.]*
|
||||
|
||||
# Install extra packages.
|
||||
RUN \
|
||||
add-pkg \
|
||||
desktop-file-utils \
|
||||
adwaita-icon-theme \
|
||||
# Icons used by folder/file selection window (when saving as).
|
||||
gnome-icon-theme \
|
||||
# A font is needed.
|
||||
ttf-dejavu \
|
||||
ffmpeg-libs \
|
||||
# The following package is used to send key presses to the X process.
|
||||
xdotool
|
||||
|
||||
@ -141,15 +103,6 @@ RUN \
|
||||
sed-patch 's|LOG_FILES=|LOG_FILES=/config/log/firefox/error.log|' /etc/logmonitor/logmonitor.conf && \
|
||||
sed-patch 's|STATUS_FILES=|STATUS_FILES=/tmp/.firefox_shm_check,/tmp/.firefox_membarrier_check|' /etc/logmonitor/logmonitor.conf
|
||||
|
||||
# Adjust the openbox config.
|
||||
RUN \
|
||||
# Maximize only the main window.
|
||||
sed-patch 's/<application type="normal">/<application type="normal" title="Mozilla Firefox">/' \
|
||||
/etc/xdg/openbox/rc.xml && \
|
||||
# Make sure the main window is always in the background.
|
||||
sed-patch '/<application type="normal" title="Mozilla Firefox">/a \ <layer>below</layer>' \
|
||||
/etc/xdg/openbox/rc.xml
|
||||
|
||||
# Generate and install favicons.
|
||||
RUN \
|
||||
APP_ICON_URL=https://github.com/jlesage/docker-templates/raw/master/jlesage/images/firefox-icon.png && \
|
||||
@ -159,8 +112,12 @@ RUN \
|
||||
COPY rootfs/ /
|
||||
COPY --from=membarrier /tmp/membarrier_check /usr/bin/
|
||||
|
||||
# Set environment variables.
|
||||
ENV APP_NAME="Firefox"
|
||||
# Set internal environment variables.
|
||||
RUN \
|
||||
set-cont-env APP_NAME "Firefox" && \
|
||||
set-cont-env APP_VERSION "$FIREFOX_VERSION" && \
|
||||
set-cont-env DOCKER_IMAGE_VERSION "$DOCKER_IMAGE_VERSION" && \
|
||||
true
|
||||
|
||||
# Define mountable directories.
|
||||
VOLUME ["/config"]
|
||||
@ -169,6 +126,6 @@ VOLUME ["/config"]
|
||||
LABEL \
|
||||
org.label-schema.name="firefox" \
|
||||
org.label-schema.description="Docker container for Firefox" \
|
||||
org.label-schema.version="$DOCKER_IMAGE_VERSION" \
|
||||
org.label-schema.version="${DOCKER_IMAGE_VERSION:-unknown}" \
|
||||
org.label-schema.vcs-url="https://github.com/jlesage/docker-firefox" \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
@ -1,22 +1,18 @@
|
||||
#!/usr/bin/with-contenv sh
|
||||
#!/bin/sh
|
||||
|
||||
set -e # Exit immediately if a command exits with a non-zero status.
|
||||
set -u # Treat unset variables as an error.
|
||||
|
||||
log() {
|
||||
echo "[cont-init.d] $(basename $0): $*"
|
||||
}
|
||||
|
||||
SND_DEV="/dev/snd"
|
||||
|
||||
if [ ! -d "$SND_DEV" ]; then
|
||||
log "sound not supported: device $SND_DEV not exposed to the container."
|
||||
echo "sound not supported: device $SND_DEV not exposed to the container."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Save the associated group.
|
||||
SND_GRP="$(find "$SND_DEV" -maxdepth 1 -not -type d -exec stat -c "%g" {} \; | sort -u | tail -n1)"
|
||||
log "sound device group $SND_GRP."
|
||||
echo "sound device group $SND_GRP."
|
||||
if [ -f /var/run/s6/container_environment/SUP_GROUP_IDS ]; then
|
||||
echo -n "," >> /var/run/s6/container_environment/SUP_GROUP_IDS
|
||||
fi
|
@ -1,15 +1,11 @@
|
||||
#!/usr/bin/with-contenv sh
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
log() {
|
||||
echo "[cont-init.d] $(basename $0): $*"
|
||||
}
|
||||
|
||||
PREF_FILE="${1:-/config/profile/prefs.js}"
|
||||
|
||||
if [ -z "$PREF_FILE" ]; then
|
||||
log "ERROR: Preference file not set."
|
||||
echo "ERROR: Preference file not set."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -22,7 +18,7 @@ do
|
||||
EVAL="$(echo "$ENV" | cut -d '=' -f2-)"
|
||||
|
||||
if [ -z "$EVAL" ]; then
|
||||
log "Skipping environment variable '$ENAME': no value set."
|
||||
echo "Skipping environment variable '$ENAME': no value set."
|
||||
continue
|
||||
fi
|
||||
|
||||
@ -36,13 +32,13 @@ do
|
||||
fi
|
||||
|
||||
if [ "$PVAL" = "UNSET" ]; then
|
||||
log "Removing preference '$PNAME'..."
|
||||
echo "Removing preference '$PNAME'..."
|
||||
sed -i "/user_pref(\"$PNAME\",.*);/d" "$PREF_FILE"
|
||||
elif grep -q "user_pref(\"$PNAME\"," "$PREF_FILE"; then
|
||||
log "Setting preference '$PNAME'..."
|
||||
echo "Setting preference '$PNAME'..."
|
||||
sed -i "s/user_pref(\"$PNAME\",.*);/user_pref(\"$PNAME\", $PVAL);/" "$PREF_FILE"
|
||||
else
|
||||
log "Setting new preference '$PNAME'..."
|
||||
echo "Setting new preference '$PNAME'..."
|
||||
echo "user_pref(\"$PNAME\", $PVAL);" >> "$PREF_FILE"
|
||||
fi
|
||||
done
|
@ -1,19 +1,15 @@
|
||||
#!/usr/bin/with-contenv sh
|
||||
#!/bin/sh
|
||||
|
||||
set -e # Exit immediately if a command exits with a non-zero status.
|
||||
set -u # Treat unset variables as an error.
|
||||
|
||||
log() {
|
||||
echo "[cont-init.d] $(basename $0): $*"
|
||||
}
|
||||
|
||||
# Make sure some directories are created.
|
||||
mkdir -p /config/downloads
|
||||
mkdir -p /config/log/firefox
|
||||
|
||||
# Generate machine id.
|
||||
if [ ! -f /etc/machine-id ]; then
|
||||
log "generating machine-id..."
|
||||
echo "generating machine-id..."
|
||||
cat /proc/sys/kernel/random/uuid | tr -d '-' > /etc/machine-id
|
||||
fi
|
||||
|
||||
@ -24,12 +20,14 @@ if [ "$SHM_SIZE_MB" -eq 64 ]; then
|
||||
else
|
||||
echo 'SHM_CHECK_PASS' > /tmp/.firefox_shm_check
|
||||
fi
|
||||
chown $USER_ID:$GROUP_ID /tmp/.firefox_shm_check
|
||||
|
||||
if /usr/bin/membarrier_check 2>/dev/null; then
|
||||
echo 'MEMBARRIER_CHECK_PASS' > /tmp/.firefox_membarrier_check
|
||||
else
|
||||
echo 'MEMBARRIER_CHECK_FAIL' > /tmp/.firefox_membarrier_check
|
||||
fi
|
||||
chown $USER_ID:$GROUP_ID /tmp/.firefox_membarrier_check
|
||||
|
||||
# Clean/optimize Firefox databases.
|
||||
#if [ -d /config/.mozilla/firefox ] && [ -d /config/profile ]; then
|
||||
@ -53,7 +51,7 @@ if [ -n "$(ls /config/profile/sessionstore-backups/*.jsonlz4 2>/dev/null)" ]; th
|
||||
if ! diff "$WORKDIR"/json "$WORKDIR"/json.orig >/dev/null; then
|
||||
jsonlz4 "$WORKDIR"/json "$WORKDIR"/jsonlz4
|
||||
mv "$WORKDIR"/jsonlz4 "$FILE"
|
||||
log "fixed display size in $FILE."
|
||||
echo "fixed display size in $FILE."
|
||||
fi
|
||||
|
||||
rm -r "$WORKDIR"
|
2
rootfs/etc/jwm/main-window-selection.jwmrc
Normal file
2
rootfs/etc/jwm/main-window-selection.jwmrc
Normal file
@ -0,0 +1,2 @@
|
||||
<Type>normal</Type>
|
||||
<Name>^Navigator</Name>
|
@ -1,2 +1,2 @@
|
||||
#!/usr/bin/with-contenv sh
|
||||
#!/bin/sh
|
||||
echo "$APP_NAME is likely to crash because it requires the membarrier system call. See the documentation of this Docker container to find out how this system call can be allowed."
|
||||
|
@ -1,2 +1,2 @@
|
||||
#!/usr/bin/with-contenv sh
|
||||
#!/bin/sh
|
||||
echo "$APP_NAME requires the membarrier system call."
|
||||
|
@ -1,2 +1,2 @@
|
||||
#!/usr/bin/with-contenv sh
|
||||
#!/bin/sh
|
||||
echo "$APP_NAME is likely to crash because of the lack of shared memory. Size of shared memory needs to be increased. See the documentation of the Docker container to find out how this can be done."
|
||||
|
@ -1,2 +1,2 @@
|
||||
#!/usr/bin/with-contenv sh
|
||||
#!/bin/sh
|
||||
echo "$APP_NAME lacks of shared memory."
|
||||
|
@ -1,2 +1,2 @@
|
||||
#!/usr/bin/with-contenv sh
|
||||
#!/bin/sh
|
||||
echo "A $APP_NAME tab crashed because of the lack of shared memory. Size of shared memory needs to be increased. See the documentation of this Docker container to find out how this can be done."
|
||||
|
@ -1,2 +1,2 @@
|
||||
#!/usr/bin/with-contenv sh
|
||||
#!/bin/sh
|
||||
echo "$APP_NAME lacks of shared memory."
|
||||
|
14
rootfs/etc/services.d/app/kill
Executable file
14
rootfs/etc/services.d/app/kill
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# When receiving SIGTERM, Firefox doesn't qui immediately and instead ask for
|
||||
# confirmation. Instead, terminate Firefox by sending the CTRL+q key presses.
|
||||
#
|
||||
|
||||
set -e # Exit immediately if a command exits with a non-zero status.
|
||||
set -u # Treat unset variables as an error.
|
||||
|
||||
xdotool key "Escape"
|
||||
xdotool key "ctrl+q"
|
||||
|
||||
# vim:ft=sh:ts=4:sw=4:et:sts=4
|
||||
|
@ -1,9 +1,9 @@
|
||||
#!/usr/bin/with-contenv sh
|
||||
#!/bin/sh
|
||||
|
||||
set -e # Exit immediately if a command exits with a non-zero status.
|
||||
set -u # Treat unset variables as an error.
|
||||
|
||||
export HOME=/config
|
||||
mkdir -p /config/profile
|
||||
firefox --version
|
||||
exec /usr/bin/firefox_wrapper --profile /config/profile --setDefaultBrowser >> /config/log/firefox/output.log 2>> /config/log/firefox/error.log
|
||||
/usr/bin/firefox --version
|
||||
exec /usr/bin/firefox --profile /config/profile --setDefaultBrowser >> /config/log/firefox/output.log 2>> /config/log/firefox/error.log
|
||||
|
@ -1,60 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# This small wrapper is used to gracefully terminate Firefox. It prevents
|
||||
# the application to receive termination signals directly. Instead, the wrapper
|
||||
# traps signals and send CTRL+q key presses to Firefox.
|
||||
#
|
||||
|
||||
FF_PID=0
|
||||
|
||||
# Gracefully terminate Firefox. This function is called when this script
|
||||
# receives a termination signal (SIGKILL, SIGINT or SIGQUIT).
|
||||
kill_firefox() {
|
||||
# Gracefully close Firefox.
|
||||
echo "Terminating Firefox..."
|
||||
xdotool key "Escape"
|
||||
xdotool key "ctrl+q"
|
||||
|
||||
# And wait for its termination.
|
||||
if [ "$FF_PID" -ne 0 ]; then
|
||||
wait $FF_PID
|
||||
exit $?
|
||||
fi
|
||||
}
|
||||
trap 'kill_firefox' TERM INT QUIT
|
||||
|
||||
# This function is called when this script exits. It makes sure that Firefox is
|
||||
# fully closed by waiting for all its processes to terminate.
|
||||
exit_wrapper() {
|
||||
echo "Waiting for Firefox to completely terminate..."
|
||||
TIMEOUT=10
|
||||
while firefox_running && [ "$TIMEOUT" -gt 0 ]; do
|
||||
TIMEOUT="$(expr "$TIMEOUT" - 1)"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ "$TIMEOUT" -gt 0 ]; then
|
||||
echo "Firefox terminated."
|
||||
else
|
||||
echo "WARNING: Firefox still not terminated."
|
||||
fi
|
||||
}
|
||||
trap 'exit_wrapper' EXIT
|
||||
|
||||
firefox_running() {
|
||||
ps | grep -v grep | grep -q '/usr/lib/firefox'
|
||||
}
|
||||
|
||||
# Make sure to terminate any existing instance.
|
||||
if firefox_running; then
|
||||
kill_firefox
|
||||
fi
|
||||
|
||||
# Start Firefox in background.
|
||||
/usr/bin/firefox "$@" &
|
||||
|
||||
# And wait for its termination.
|
||||
FF_PID=$!
|
||||
wait $FF_PID
|
||||
exit $?
|
Loading…
x
Reference in New Issue
Block a user