Skip to content

Commit

Permalink
Merge pull request #71 from scottyhardy/feature/no_rdp_#68
Browse files Browse the repository at this point in the history
Feature/no rdp #68
  • Loading branch information
scottyhardy committed Jun 16, 2020
2 parents 3a82d4f + 27ea889 commit 1f23f1c
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 20 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ services:
- docker

env:
- WINE_BRANCH=devel
- WINE_BRANCH=stable
- WINE_BRANCH=devel NO_RDP=no
- WINE_BRANCH=devel NO_RDP=yes
- WINE_BRANCH=stable NO_RDP=no
- WINE_BRANCH=stable NO_RDP=yes

script:
- bash build
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
ARG TAG=latest
FROM scottyhardy/docker-remote-desktop:$TAG
ARG BASE_IMAGE="scottyhardy/docker-remote-desktop"
ARG TAG="latest"
FROM ${BASE_IMAGE}:${TAG}

# Install prerequisites
RUN apt-get update \
&& DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates \
cabextract \
git \
gosu \
gpg-agent \
p7zip \
Expand All @@ -21,7 +23,7 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

# Install wine
ARG WINE_BRANCH=stable
ARG WINE_BRANCH="stable"
RUN wget -O- -nv https://dl.winehq.org/wine-builds/winehq.key | apt-key add - \
&& apt-add-repository "deb https://dl.winehq.org/wine-builds/ubuntu/ $(grep VERSION_CODENAME= /etc/os-release | cut -d= -f2) main" \
&& dpkg --add-architecture i386 \
Expand Down
24 changes: 20 additions & 4 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,34 @@ get_os_codename () {
}


# Array of command line args to be passed to the build command
BUILD_ARGS=("$@")

# Default values
BUILD_CMD="docker build"
DOCKER_REPO="${DOCKER_REPO:-docker-wine}"
NO_RDP="${NO_RDP:-no}"
URL="https://dl.winehq.org/wine-builds/ubuntu/dists/"
WINE_BRANCH="${WINE_BRANCH:-stable}"

# Get the codename for latest version of wine-${WINE-BRANCH}
UBUNTU_CODENAME="$(get_os_codename "${URL}")"

# Just use latest tag if unable to be determined
# Just use latest if codename unable to be determined
if [ -n "${UBUNTU_CODENAME}" ]; then
echo "Found latest version of wine-${WINE_BRANCH} is available on Ubuntu ${UBUNTU_CODENAME}"
TAG="ubuntu-${UBUNTU_CODENAME}"
else
echo "WARNING: Unable to determine version of Ubuntu to use with Wine, so using latest"
TAG="latest"
UBUNTU_CODENAME="latest"
fi

# Use standard Ubuntu image if using NO_RDP
if echo "${NO_RDP}" | grep -q -i -E "^(yes|on|true|1)$"; then
BASE_IMAGE="ubuntu"
TAG="${UBUNTU_CODENAME}"
else
BASE_IMAGE="scottyhardy/docker-remote-desktop"
TAG="ubuntu-${UBUNTU_CODENAME}"
fi

if ! docker system info >/dev/null 2>&1; then
Expand All @@ -79,4 +91,8 @@ if ! docker system info >/dev/null 2>&1; then
fi
fi

${BUILD_CMD} "${BUILD_ARGS[@]}" --build-arg="TAG=${TAG}" --build-arg="WINE_BRANCH=${WINE_BRANCH}" -t "${DOCKER_REPO}" .
${BUILD_CMD} "${BUILD_ARGS[@]}" \
--build-arg="BASE_IMAGE=${BASE_IMAGE}" \
--build-arg="TAG=${TAG}" \
--build-arg="WINE_BRANCH=${WINE_BRANCH}" \
-t "${DOCKER_REPO}" .
33 changes: 22 additions & 11 deletions deploy
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,43 @@

WINE_BRANCH="${WINE_BRANCH:-stable}"
TIMESTAMP="$(date +"%Y%m%d")"
NO_RDP="${NO_RDP:-no}"

# Run container and extract wine version
VER="$(docker run -it --rm "${DOCKER_REPO}" /bin/bash -c "dpkg -s wine-${WINE_BRANCH} | grep '^Version:\s' | awk '{print \$2}' | sed -E 's/~.*$//'" | tr -d "\r")"
WINE_VER="$(docker run -it --rm "${DOCKER_REPO}" /bin/bash -c "dpkg -s wine-${WINE_BRANCH} | grep '^Version:\s' | awk '{print \$2}' | sed -E 's/~.*$//'" | tr -d "\r")"

if [ -n "${VER}" ]; then
echo "Found wine version '${VER}'"
if echo "${WINE_VER}" | grep -q -E "^[0-9]+(\.[0-9]+)*$"; then
echo "Found wine version '${WINE_VER}'"
else
echo "ERROR: Unable to determine wine version"
exit 1
fi

# Append '-nordp' to the image tag only if NO_RDP is true
if echo "${NO_RDP}" | grep -q -i -E "^(yes|on|true|1)$"; then
SUFFIX="-nordp"
elif echo "${NO_RDP}" | grep -q -i -E "^(no|off|false|0)$"; then
SUFFIX=""
else
echo "ERROR: Invalid value '${NO_RDP}' used for NO_RDP"
exit 1
fi

# Generate tags
docker tag "${DOCKER_REPO}" "${DOCKER_USERNAME}/${DOCKER_REPO}:${WINE_BRANCH}"
docker tag "${DOCKER_REPO}" "${DOCKER_USERNAME}/${DOCKER_REPO}:${WINE_BRANCH}-${VER}"
docker tag "${DOCKER_REPO}" "${DOCKER_USERNAME}/${DOCKER_REPO}:${WINE_BRANCH}-${VER}-${TIMESTAMP}"
docker tag "${DOCKER_REPO}" "${DOCKER_USERNAME}/${DOCKER_REPO}:${WINE_BRANCH}${SUFFIX}"
docker tag "${DOCKER_REPO}" "${DOCKER_USERNAME}/${DOCKER_REPO}:${WINE_BRANCH}-${WINE_VER}${SUFFIX}"
docker tag "${DOCKER_REPO}" "${DOCKER_USERNAME}/${DOCKER_REPO}:${WINE_BRANCH}-${WINE_VER}-${TIMESTAMP}${SUFFIX}"

# Login to Docker Hub
echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin

# Push the image and tags
docker push "${DOCKER_USERNAME}/${DOCKER_REPO}:${WINE_BRANCH}"
docker push "${DOCKER_USERNAME}/${DOCKER_REPO}:${WINE_BRANCH}-${VER}"
docker push "${DOCKER_USERNAME}/${DOCKER_REPO}:${WINE_BRANCH}-${VER}-${TIMESTAMP}"
docker push "${DOCKER_USERNAME}/${DOCKER_REPO}:${WINE_BRANCH}${SUFFIX}"
docker push "${DOCKER_USERNAME}/${DOCKER_REPO}:${WINE_BRANCH}-${WINE_VER}${SUFFIX}"
docker push "${DOCKER_USERNAME}/${DOCKER_REPO}:${WINE_BRANCH}-${WINE_VER}-${TIMESTAMP}${SUFFIX}"

# Push the wine-stable image as latest tag
if [ "${WINE_BRANCH}" == "stable" ]; then
docker tag "${DOCKER_REPO}" "${DOCKER_USERNAME}/${DOCKER_REPO}:latest"
docker push "${DOCKER_USERNAME}/${DOCKER_REPO}:latest"
docker tag "${DOCKER_REPO}" "${DOCKER_USERNAME}/${DOCKER_REPO}:latest${SUFFIX}"
docker push "${DOCKER_USERNAME}/${DOCKER_REPO}:latest${SUFFIX}"
fi
18 changes: 18 additions & 0 deletions docker-wine
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ print_help () {
echo " --as-me Start the container using your current username, UID and"
echo " GID (default when alternate --home value specified)"
echo " --notty Start container attached with no tty"
echo " --nordp Use a version of the docker-wine image that does not"
echo " include RDP server packages for a reduced image size"
echo " --rdp Shortcut for --rdp=interactive"
echo " --rdp=OPTION Runs docker-wine container with Remote Desktop Protocol"
echo " server"
Expand Down Expand Up @@ -228,6 +230,15 @@ run_container () {
add_run_arg --workdir="${WORKDIR}"
add_run_arg_timezone

# Append -nordp to image tag if NO_RDP is set to 'yes'
if [ "${NO_RDP}" == "yes" ]; then

# Only append if image tag specified does not already end in -nordp
if ! echo "${IMAGE_TAG}" | grep -q -E "\-nordp$"; then
IMAGE_TAG="${IMAGE_TAG}-nordp"
fi
fi

# Grab the latest image from docker hub or use the locally built version
if [ "${USE_LOCAL_IMAGE}" == "no" ]; then
[ "${DOCKER_PULL_IMAGE}" == "yes" ] && docker pull "${DOCKER_IMAGE}:${IMAGE_TAG}"
Expand Down Expand Up @@ -300,6 +311,9 @@ while [ $# -gt 0 ]; do
--notty)
NOTTY="yes"
;;
--nordp)
NO_RDP="yes"
;;
--rdp)
USE_RDP_SERVER="interactive"
;;
Expand Down Expand Up @@ -385,6 +399,10 @@ if [ "${USE_RDP_SERVER}" != "no" ] && [ -n "${CMD_ARGS[0]}" ]; then
exit 1
fi

if [ "${USE_RDP_SERVER}" != "no" ] && [ "${NO_RDP}" != "no" ]; then
echo "ERROR: Cannot combine conflicting options --rdp and --nordp"
exit 1
fi

# Run xvfb and send everything into the void
if [ "${XVFB}" == "yes" ] ; then
Expand Down
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ if echo "${RDP_SERVER}" | grep -q -i -E "^(no|off|false|0)$"; then
# Run in RDP server mode
elif echo "${RDP_SERVER}" | grep -q -i -E "^(yes|on|true|1)$"; then

# Exit if using nordp image
if ! [ -f /usr/sbin/xrdp ]; then
echo "ERROR: Unable to start RDP server as it is not included in this version of the docker-wine image"
exit 1
fi

# Start xrdp sesman service
/usr/sbin/xrdp-sesman

Expand Down

0 comments on commit 1f23f1c

Please sign in to comment.