labs:docker-lab2-docker-wine
Table of Contents
Installation
run:
./docker-wine --local
build: Dockerfile ./build.sh ubuntu-stable
Scripts de build
VERSION
2.0.1
build.sh
#!/bin/bash
if [ $# -lt 1 ]; then
echo "ERROR: Please specify a build target"
echo "e.g."
echo " $0 ubuntu-stable"
exit 1
fi
BUILD_TARGET="$1"
VERSION=$(cat ./VERSION)
source ./build_args/${BUILD_TARGET}
docker build \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg GECKO_VER=$GECKO_VER \
--build-arg GIT_REV=$(git rev-parse HEAD) \
--build-arg IMAGE_VER=$VERSION \
--build-arg MONO_VER=$MONO_VER \
--build-arg WINE_VER=$WINE_VER \
--build-arg WINEBRANCH=$WINEBRANCH \
-t docker-wine:${WINEBRANCH}-${VERSION}-local \
-t docker-wine .
build_args/ubuntu-stable
#!/bin/bash export WINEBRANCH="stable" export WINE_VER="4.0.1~bionic" export MONO_VER="4.7.5" export GECKO_VER="2.47"
Environnement Docker
DockerFile
FROM ubuntu:bionic
RUN export DEBIAN_FRONTEND="noninteractive" \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates \
cabextract \
gosu \
gpg-agent \
p7zip \
pulseaudio-utils \
software-properties-common \
unzip \
wget \
winbind \
zenity \
&& rm -rf /var/lib/apt/lists/*
ARG WINEBRANCH
ARG WINE_VER
RUN wget https://dl.winehq.org/wine-builds/winehq.key \
&& apt-key add winehq.key \
&& apt-add-repository "deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main" \
&& dpkg --add-architecture i386 \
&& apt-get update \
&& apt-get install -y --install-recommends winehq-${WINEBRANCH}="${WINE_VER}" \
&& rm -rf /var/lib/apt/lists/* \
&& rm winehq.key
# Download mono and gecko
ARG MONO_VER
ARG GECKO_VER
RUN mkdir -p /usr/share/wine/mono /usr/share/wine/gecko \
&& wget https://dl.winehq.org/wine/wine-mono/${MONO_VER}/wine-mono-${MONO_VER}.msi \
-O /usr/share/wine/mono/wine-mono-${MONO_VER}.msi \
&& wget https://dl.winehq.org/wine/wine-gecko/${GECKO_VER}/wine_gecko-${GECKO_VER}-x86.msi \
-O /usr/share/wine/gecko/wine_gecko-${GECKO_VER}-x86.msi \
&& wget https://dl.winehq.org/wine/wine-gecko/${GECKO_VER}/wine_gecko-${GECKO_VER}-x86_64.msi \
-O /usr/share/wine/gecko/wine_gecko-${GECKO_VER}-x86_64.msi
# Download winetricks
RUN wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks \
-O /usr/bin/winetricks \
&& chmod +rx /usr/bin/winetricks
# Create user and take ownership of files
RUN groupadd -g 1010 wineuser \
&& useradd --shell /bin/bash --uid 1010 --gid 1010 --create-home --home-dir /home/wineuser wineuser \
&& chown -R wineuser:wineuser /home/wineuser
VOLUME /home/wineuser
COPY pulse-client.conf /etc/pulse/client.conf
COPY entrypoint.sh /usr/bin/entrypoint
WORKDIR /home/wineuser
ARG IMAGE_VER
ARG BUILD_DATE
ARG GIT_REV
LABEL \
org.opencontainers.image.authors="scottyhardy <scotthardy42@outlook.com>" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.description="Docker image that includes Wine and Winetricks for running Windows applications on Linux and macOS" \
org.opencontainers.image.documentation="https://github.com/scottyhardy/docker-wine/blob/${IMAGE_VER}/README.md" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision="${GIT_REV}" \
org.opencontainers.image.source="https://github.com/scottyhardy/docker-wine.git" \
org.opencontainers.image.title="docker-wine" \
org.opencontainers.image.url="https://github.com/scottyhardy/docker-wine" \
org.opencontainers.image.vendor="scottyhardy" \
org.opencontainers.image.version="${IMAGE_VER}"
ENTRYPOINT ["/usr/bin/entrypoint"]
CMD ["/bin/bash"]
entrypoint.sh
#!/bin/bash
# Copy and take ownership of .Xauthority
if [ -f /root/.Xauthority ]; then
cp /root/.Xauthority /home/wineuser
chown wineuser:wineuser /home/wineuser/.Xauthority
fi
exec gosu wineuser "$@"
Scripts interactifs
docker-wine
FROM ubuntu:bionic
RUN export DEBIAN_FRONTEND="noninteractive" \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates \
cabextract \
gosu \
gpg-agent \
p7zip \
pulseaudio-utils \
software-properties-common \
unzip \
wget \
winbind \
zenity \
&& rm -rf /var/lib/apt/lists/*
ARG WINEBRANCH
ARG WINE_VER
RUN wget https://dl.winehq.org/wine-builds/winehq.key \
&& apt-key add winehq.key \
&& apt-add-repository "deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main" \
&& dpkg --add-architecture i386 \
&& apt-get update \
&& apt-get install -y --install-recommends winehq-${WINEBRANCH}="${WINE_VER}" \
&& rm -rf /var/lib/apt/lists/* \
&& rm winehq.key
# Download mono and gecko
ARG MONO_VER
ARG GECKO_VER
RUN mkdir -p /usr/share/wine/mono /usr/share/wine/gecko \
&& wget https://dl.winehq.org/wine/wine-mono/${MONO_VER}/wine-mono-${MONO_VER}.msi \
-O /usr/share/wine/mono/wine-mono-${MONO_VER}.msi \
&& wget https://dl.winehq.org/wine/wine-gecko/${GECKO_VER}/wine_gecko-${GECKO_VER}-x86.msi \
-O /usr/share/wine/gecko/wine_gecko-${GECKO_VER}-x86.msi \
&& wget https://dl.winehq.org/wine/wine-gecko/${GECKO_VER}/wine_gecko-${GECKO_VER}-x86_64.msi \
-O /usr/share/wine/gecko/wine_gecko-${GECKO_VER}-x86_64.msi
# Download winetricks
RUN wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks \
-O /usr/bin/winetricks \
&& chmod +rx /usr/bin/winetricks
# Create user and take ownership of files
RUN groupadd -g 1010 wineuser \
&& useradd --shell /bin/bash --uid 1010 --gid 1010 --create-home --home-dir /home/wineuser wineuser \
&& chown -R wineuser:wineuser /home/wineuser
VOLUME /home/wineuser
COPY pulse-client.conf /etc/pulse/client.conf
COPY entrypoint.sh /usr/bin/entrypoint
WORKDIR /home/wineuser
ARG IMAGE_VER
ARG BUILD_DATE
ARG GIT_REV
LABEL \
org.opencontainers.image.authors="scottyhardy <scotthardy42@outlook.com>" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.description="Docker image that includes Wine and Winetricks for running Windows applications on Linux and macOS" \
org.opencontainers.image.documentation="https://github.com/scottyhardy/docker-wine/blob/${IMAGE_VER}/README.md" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision="${GIT_REV}" \
org.opencontainers.image.source="https://github.com/scottyhardy/docker-wine.git" \
org.opencontainers.image.title="docker-wine" \
org.opencontainers.image.url="https://github.com/scottyhardy/docker-wine" \
org.opencontainers.image.vendor="scottyhardy" \
org.opencontainers.image.version="${IMAGE_VER}"
ENTRYPOINT ["/usr/bin/entrypoint"]
CMD ["/bin/bash"]
pulse-client.conf
# Connect to the host's server using the mounted UNIX socket default-server = unix:/tmp/pulse-socket # Prevent a server running in the container autospawn = no daemon-binary = /bin/true # Prevent the use of shared memory enable-shm = false
hooks
hooks/build
#!/bin/bash
source build_args/ubuntu-stable
echo "GECKO_VER = $GECKO_VER"
echo "IMAGE_VER = $(cat VERSION)"
echo "MONO_VER = $MONO_VER"
echo "WINE_VER = $WINE_VER"
echo "WINEBRANCH = $WINEBRANCH"
docker build \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg GECKO_VER=$GECKO_VER \
--build-arg GIT_REV=$SOURCE_COMMIT \
--build-arg IMAGE_VER=$(cat VERSION) \
--build-arg MONO_VER=$MONO_VER \
--build-arg WINE_VER=$WINE_VER \
--build-arg WINEBRANCH=$WINEBRANCH \
-f $DOCKERFILE_PATH \
-t $IMAGE_NAME .
hooks/post_push
#!/bin/bash
source build_args/ubuntu-stable
VERSION=$(cat VERSION)
if [ "$SOURCE_BRANCH" == "dev" ]; then
docker tag $IMAGE_NAME ${DOCKER_REPO}:dev-${WINEBRANCH}-${VERSION}
docker push ${DOCKER_REPO}:dev-${WINEBRANCH}-${VERSION}
else
docker tag $IMAGE_NAME ${DOCKER_REPO}:latest
docker push ${DOCKER_REPO}:latest
docker tag $IMAGE_NAME ${DOCKER_REPO}:${WINEBRANCH}-${VERSION}
docker push ${DOCKER_REPO}:${WINEBRANCH}-${VERSION}
fi
labs/docker-lab2-docker-wine.txt · Last modified: 2025/02/19 10:59 by 127.0.0.1
