diff mbox series

[1/2] docker: Use Ubuntu ports repositories on non-x86 architectures

Message ID 20190501062718.17548-1-ruscur@russell.cc
State Accepted
Headers show
Series [1/2] docker: Use Ubuntu ports repositories on non-x86 architectures | expand

Commit Message

Russell Currey May 1, 2019, 6:27 a.m. UTC
This should allow Patchwork to run "out of the box" in Docker on any
architecture with a) an Ubuntu port and b) support in the Postgres
multiarch Docker image, which includes at least arm64 and ppc64le.

It's a little gross hacking the Dockerfile like this, but I'm not sure
there's a more elegant way to do it.  Unfortunately it doesn't seem like
there's any way to do conditional COPY, and anything in RUN is plain
/bin/sh, so that's why it looks like it does.

Tested on ppc64le and on x86_64.

Signed-off-by: Russell Currey <ruscur@russell.cc>
---
 tools/docker/Dockerfile        | 14 ++++++++++++--
 tools/docker/trusty-ports.list |  3 +++
 tools/docker/xenial-ports.list |  3 +++
 3 files changed, 18 insertions(+), 2 deletions(-)
 create mode 100644 tools/docker/trusty-ports.list
 create mode 100644 tools/docker/xenial-ports.list

Comments

Andrew Donnellan May 1, 2019, 7:35 a.m. UTC | #1
On 1/5/19 4:27 pm, Russell Currey wrote:
> This should allow Patchwork to run "out of the box" in Docker on any
> architecture with a) an Ubuntu port and b) support in the Postgres
> multiarch Docker image, which includes at least arm64 and ppc64le.
> 
> It's a little gross hacking the Dockerfile like this, but I'm not sure
> there's a more elegant way to do it.  Unfortunately it doesn't seem like
> there's any way to do conditional COPY, and anything in RUN is plain
> /bin/sh, so that's why it looks like it does.
> 
> Tested on ppc64le and on x86_64.
> 
> Signed-off-by: Russell Currey <ruscur@russell.cc>

Gross, but alas. One day ppc64le will graduate to being mirrored like a 
real architecture...

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

> ---
>   tools/docker/Dockerfile        | 14 ++++++++++++--
>   tools/docker/trusty-ports.list |  3 +++
>   tools/docker/xenial-ports.list |  3 +++
>   3 files changed, 18 insertions(+), 2 deletions(-)
>   create mode 100644 tools/docker/trusty-ports.list
>   create mode 100644 tools/docker/xenial-ports.list
> 
> diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
> index eef40e4..76bb6b2 100644
> --- a/tools/docker/Dockerfile
> +++ b/tools/docker/Dockerfile
> @@ -15,11 +15,21 @@ ENV DJANGO_SETTINGS_MODULE patchwork.settings.dev
>   ENV DEBIAN_FRONTEND noninteractive
>   ENV PYTHONUNBUFFERED 1
>   
> +
>   # System
>   # trusty and findutils is for python3.4; xenial is for python3.5
>   # TODO(stephenfin): Are curl, unzip required?
> -COPY tools/docker/trusty.list /etc/apt/sources.list.d/trusty.list
> -COPY tools/docker/xenial.list /etc/apt/sources.list.d/xenial.list
> +COPY tools/docker/*.list /etc/apt/sources.list.d/
> +
> +RUN cd /etc/apt/sources.list.d; \
> +    echo $(uname -m) > /tmp/arch; \
> +    if [ $(cat /tmp/arch) != 'x86_64' ] && grep -q -v "i.86" /tmp/arch; then \
> +        mv trusty-ports.list trusty.list; \
> +        mv xenial-ports.list xenial.list; \
> +    else \
> +        rm *-ports.list; \
> +    fi
> +
>   RUN apt-get update -qq && \
>       apt-get install -y --no-install-recommends --allow-downgrades \
>       python-dev python-pip python-setuptools python-wheel \
> diff --git a/tools/docker/trusty-ports.list b/tools/docker/trusty-ports.list
> new file mode 100644
> index 0000000..ebcf4fa
> --- /dev/null
> +++ b/tools/docker/trusty-ports.list
> @@ -0,0 +1,3 @@
> +deb http://ports.ubuntu.com/ubuntu-ports/ trusty main
> +deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main
> +deb http://ports.ubuntu.com/ubuntu-ports/ trusty-security main
> diff --git a/tools/docker/xenial-ports.list b/tools/docker/xenial-ports.list
> new file mode 100644
> index 0000000..d84641f
> --- /dev/null
> +++ b/tools/docker/xenial-ports.list
> @@ -0,0 +1,3 @@
> +deb http://ports.ubuntu.com/ubuntu-ports/ xenial main
> +deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main
> +deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security main
>
Daniel Axtens May 3, 2019, 6:16 a.m. UTC | #2
Russell Currey <ruscur@russell.cc> writes:

> This should allow Patchwork to run "out of the box" in Docker on any
> architecture with a) an Ubuntu port and b) support in the Postgres
> multiarch Docker image, which includes at least arm64 and ppc64le.
>
> It's a little gross hacking the Dockerfile like this, but I'm not sure
> there's a more elegant way to do it.  Unfortunately it doesn't seem like
> there's any way to do conditional COPY, and anything in RUN is plain
> /bin/sh, so that's why it looks like it does.
>
> Tested on ppc64le and on x86_64.
>
> Signed-off-by: Russell Currey <ruscur@russell.cc>
> ---
>  tools/docker/Dockerfile        | 14 ++++++++++++--
>  tools/docker/trusty-ports.list |  3 +++
>  tools/docker/xenial-ports.list |  3 +++
>  3 files changed, 18 insertions(+), 2 deletions(-)
>  create mode 100644 tools/docker/trusty-ports.list
>  create mode 100644 tools/docker/xenial-ports.list
>
> diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
> index eef40e4..76bb6b2 100644
> --- a/tools/docker/Dockerfile
> +++ b/tools/docker/Dockerfile
> @@ -15,11 +15,21 @@ ENV DJANGO_SETTINGS_MODULE patchwork.settings.dev
>  ENV DEBIAN_FRONTEND noninteractive
>  ENV PYTHONUNBUFFERED 1
>  
> +
>  # System
>  # trusty and findutils is for python3.4; xenial is for python3.5
>  # TODO(stephenfin): Are curl, unzip required?
> -COPY tools/docker/trusty.list /etc/apt/sources.list.d/trusty.list
> -COPY tools/docker/xenial.list /etc/apt/sources.list.d/xenial.list
> +COPY tools/docker/*.list /etc/apt/sources.list.d/
> +
> +RUN cd /etc/apt/sources.list.d; \
> +    echo $(uname -m) > /tmp/arch; \
> +    if [ $(cat /tmp/arch) != 'x86_64' ] && grep -q -v "i.86" /tmp/arch; then \
> +        mv trusty-ports.list trusty.list; \
> +        mv xenial-ports.list xenial.list; \
> +    else \
> +        rm *-ports.list; \
> +    fi
> +

Yeah, this is pretty gross, but oh well. I'm not in general super
bothered by gross Dockerfiles, especially where it keeps mess out of the
code proper.

Applied the series, thanks for updating the docs in the next patch.

As an aside, I wonder when we can drop py34 - I don't think django2
supports it so hopefully soon...

Regards,
Daniel


>  RUN apt-get update -qq && \
>      apt-get install -y --no-install-recommends --allow-downgrades \
>      python-dev python-pip python-setuptools python-wheel \
> diff --git a/tools/docker/trusty-ports.list b/tools/docker/trusty-ports.list
> new file mode 100644
> index 0000000..ebcf4fa
> --- /dev/null
> +++ b/tools/docker/trusty-ports.list
> @@ -0,0 +1,3 @@
> +deb http://ports.ubuntu.com/ubuntu-ports/ trusty main
> +deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main
> +deb http://ports.ubuntu.com/ubuntu-ports/ trusty-security main
> diff --git a/tools/docker/xenial-ports.list b/tools/docker/xenial-ports.list
> new file mode 100644
> index 0000000..d84641f
> --- /dev/null
> +++ b/tools/docker/xenial-ports.list
> @@ -0,0 +1,3 @@
> +deb http://ports.ubuntu.com/ubuntu-ports/ xenial main
> +deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main
> +deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security main
> -- 
> 2.21.0
>
> _______________________________________________
> Patchwork mailing list
> Patchwork@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork
diff mbox series

Patch

diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index eef40e4..76bb6b2 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -15,11 +15,21 @@  ENV DJANGO_SETTINGS_MODULE patchwork.settings.dev
 ENV DEBIAN_FRONTEND noninteractive
 ENV PYTHONUNBUFFERED 1
 
+
 # System
 # trusty and findutils is for python3.4; xenial is for python3.5
 # TODO(stephenfin): Are curl, unzip required?
-COPY tools/docker/trusty.list /etc/apt/sources.list.d/trusty.list
-COPY tools/docker/xenial.list /etc/apt/sources.list.d/xenial.list
+COPY tools/docker/*.list /etc/apt/sources.list.d/
+
+RUN cd /etc/apt/sources.list.d; \
+    echo $(uname -m) > /tmp/arch; \
+    if [ $(cat /tmp/arch) != 'x86_64' ] && grep -q -v "i.86" /tmp/arch; then \
+        mv trusty-ports.list trusty.list; \
+        mv xenial-ports.list xenial.list; \
+    else \
+        rm *-ports.list; \
+    fi
+
 RUN apt-get update -qq && \
     apt-get install -y --no-install-recommends --allow-downgrades \
     python-dev python-pip python-setuptools python-wheel \
diff --git a/tools/docker/trusty-ports.list b/tools/docker/trusty-ports.list
new file mode 100644
index 0000000..ebcf4fa
--- /dev/null
+++ b/tools/docker/trusty-ports.list
@@ -0,0 +1,3 @@ 
+deb http://ports.ubuntu.com/ubuntu-ports/ trusty main
+deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main
+deb http://ports.ubuntu.com/ubuntu-ports/ trusty-security main
diff --git a/tools/docker/xenial-ports.list b/tools/docker/xenial-ports.list
new file mode 100644
index 0000000..d84641f
--- /dev/null
+++ b/tools/docker/xenial-ports.list
@@ -0,0 +1,3 @@ 
+deb http://ports.ubuntu.com/ubuntu-ports/ xenial main
+deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main
+deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security main