summaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2018-11-30 04:40:11 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2018-11-30 04:40:11 +0100
commitf6a4442fa8df8cdc70b79ee793dee6deaf896f05 (patch)
tree2ffa45f7df7f78412028871d0703c489b75f8bd2 /docker
parent7885f3e34e6db561fe4ddbf9d748b5273d86a52d (diff)
Support building docker images
Diffstat (limited to 'docker')
-rw-r--r--docker/Dockerfile23
-rwxr-xr-xdocker/init.sh32
2 files changed, 55 insertions, 0 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 0000000..dc0576c
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,23 @@
+FROM debian:stable-slim as builder
+
+WORKDIR /root/
+
+RUN apt-get update
+RUN apt-get -y --no-install-recommends install build-essential subversion fakeroot gawk gpg git wget ca-certificates
+
+RUN git clone https://github.com/mikma/lxd-openwrt.git
+
+RUN (cd lxd-openwrt && ./build.sh -v snapshot --type plain)
+RUN mkdir rootfs
+RUN tar xzf /root/lxd-openwrt/bin/openwrt-snapshot-x86-64-plain.tar.gz -C rootfs
+
+
+FROM scratch
+
+COPY --from=builder /root/rootfs /
+
+COPY init.sh /
+
+RUN mkdir -p /var/lock && opkg update && opkg install luci-ssl
+
+ENTRYPOINT ["/init.sh"]
diff --git a/docker/init.sh b/docker/init.sh
new file mode 100755
index 0000000..2f01a76
--- /dev/null
+++ b/docker/init.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+gw4=$(ip -4 route show|grep ^default|sed -e 's/.* via \([0-9.]*\)\W.*/\1/')
+gw6=$(ip -6 route show|grep ^default|sed -e 's/.* via \([0-9a-f:]*\)\W.*/\1/')
+ipmask4=$(ip -4 addr show eth0|grep inet|sed -e 's|.* inet \([0-9.]*\)/\([0-9]*\)\W.*|\1 \2|')
+ip4=$(echo $ipmask4|cut -d' ' -f 1)
+mask4=$(echo $ipmask4|cut -d' ' -f 2)
+ip6=$(ip -6 addr show eth0|grep inet6|grep global|sed -e 's|.* inet6 \([0-9a-f:]*\)/\([0-9]*\)\W.*|\1/\2|')
+
+cat >> /etc/uci-defaults/60_docker-network << EOF
+#!/bin/sh
+
+uci set network.lan.proto=static
+uci set network.lan.ipaddr=$ip4
+uci set network.lan.netmask=$mask4
+uci set network.lan.gateway=$gw4
+uci set network.lan.ip6addr=$ip6
+uci set network.lan.ip6gw=$gw6
+uci delete network.lan.type
+uci delete network.lan6
+uci commit network.lan
+exit 0
+EOF
+
+cat >> /etc/uci-defaults/50_passwd << EOF
+#!/bin/sh
+
+echo -e "openwrtpassword\nopenwrtpassword" | passwd
+exit 0
+EOF
+
+exec /sbin/init "$@"