mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-12-22 19:31:35 +00:00
Add docker development environments for arm64v8 and arm32v7
This commit is contained in:
parent
91e6bb5be1
commit
3e7fc95144
8 changed files with 397 additions and 8 deletions
14
README.md
14
README.md
|
@ -59,8 +59,18 @@ dependencies already present
|
|||
$ git clone https://git.asonix.dog/asonix/pict-rs
|
||||
$ cd pict-rs/docker/dev
|
||||
$ ./dev.sh
|
||||
$ cargo build
|
||||
$ cargo run
|
||||
$ build
|
||||
$ run -- -p data/
|
||||
```
|
||||
Development environments are provided for amd64, arm32v7, and arm64v8. By default `dev.sh` will load
|
||||
into the contianer targetting amd64, but arch arguments can be passed to change the target.
|
||||
```
|
||||
$ ./dev.sh arm32v7
|
||||
$ build
|
||||
|
||||
# note:
|
||||
# This command may not work unless qemu-user-static has been configured for your docker instance
|
||||
$ run -- -p data/
|
||||
```
|
||||
|
||||
### API
|
||||
|
|
|
@ -158,6 +158,7 @@ ENV \
|
|||
COPY --from=rust --chown=build:build /opt/build/.cargo /opt/build/.cargo
|
||||
COPY --from=rust --chown=build:build /opt/build/.rustup /opt/build/.rustup
|
||||
COPY --from=imagemagick-builder /usr/local/ /usr/local
|
||||
COPY root/ /
|
||||
|
||||
USER build
|
||||
|
169
docker/dev/Dockerfile.arm32v7
Normal file
169
docker/dev/Dockerfile.arm32v7
Normal file
|
@ -0,0 +1,169 @@
|
|||
# Basic cross-build environment
|
||||
FROM ubuntu:20.04 as cross-build
|
||||
|
||||
ARG UID=1000
|
||||
ARG GID=1000
|
||||
|
||||
ENV \
|
||||
ARCH=armhf \
|
||||
HOST=arm-unknown-linux \
|
||||
TOOL=arm-linux-gnueabihf \
|
||||
TARGET=armv7-unknown-linux-gnueabihf \
|
||||
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \
|
||||
CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \
|
||||
CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ \
|
||||
BUILD_MODE=release
|
||||
|
||||
ENV \
|
||||
TOOLCHAIN=stable \
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
PKG_CONFIG_ALLOW_CROSS=1 \
|
||||
PKG_CONFIG_PATH=/usr/lib/$TOOL/pkgconfig:/usr/lib/pkgconfig \
|
||||
LD_LIBRARY_PATH=/usr/lib/$TOOL:/usr/$TOOL/lib \
|
||||
LD_RUN_PATH=/usr/lib/$TOOL:/usr/$TOOL/lib \
|
||||
LDFLAGS="-L/usr/lib/$TOOL -L/usr/$TOOL/lib -Wl,-rpath-link,/usr/lib/$TOOL -Wl,-rpath-link,/usr/$TOOL/lib" \
|
||||
CFLAGS="-I/usr/include/$TOOL -I/usr/$TOOL/include -I/usr/include" \
|
||||
CPPFLAGS="-I/usr/include/$TOOL -I/usr/$TOOL/include -I/usr/include"
|
||||
|
||||
RUN \
|
||||
sed 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch-=amd64,i386] http:\/\/ports.ubuntu.com\/ubuntu-ports\//g' /etc/apt/sources.list > /etc/apt/sources.list.d/ports.list && \
|
||||
sed -i 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch=amd64,i386] http:\/\/\1.archive.ubuntu.com\/ubuntu\//g' /etc/apt/sources.list && \
|
||||
addgroup --gid $GID build && \
|
||||
adduser \
|
||||
--disabled-password \
|
||||
--gecos "" \
|
||||
--ingroup build \
|
||||
--uid $UID \
|
||||
--home /opt/build \
|
||||
build && \
|
||||
dpkg --add-architecture $ARCH && \
|
||||
apt-get update && \
|
||||
apt-get upgrade -y && \
|
||||
apt-get install -y \
|
||||
pkg-config \
|
||||
build-essential \
|
||||
crossbuild-essential-$ARCH
|
||||
|
||||
WORKDIR /opt/build
|
||||
|
||||
|
||||
# Environment for ImageMagick
|
||||
FROM cross-build as imagemagick-builder
|
||||
|
||||
RUN \
|
||||
apt-get install -y \
|
||||
libltdl-dev:$ARCH \
|
||||
libjpeg-dev:$ARCH \
|
||||
libpng-dev:$ARCH \
|
||||
libwebp-dev:$ARCH \
|
||||
liblzma-dev:$ARCH \
|
||||
libxml2-dev:$ARCH
|
||||
|
||||
ADD --chown=build:build https://imagemagick.org/download/ImageMagick.tar.gz /opt/build/ImageMagick.tar.gz
|
||||
|
||||
USER build
|
||||
|
||||
RUN \
|
||||
tar zxf ImageMagick.tar.gz && \
|
||||
mv ImageMagick-* ImageMagick
|
||||
|
||||
WORKDIR /opt/build/ImageMagick
|
||||
|
||||
RUN \
|
||||
./configure \
|
||||
CC=$TOOL-gcc \
|
||||
CXX=$TOOL-g++ \
|
||||
--enable-shared \
|
||||
--with-modules \
|
||||
--disable-static \
|
||||
--disable-docs \
|
||||
--prefix=/usr/local \
|
||||
--with-utilities=no \
|
||||
--with-magick-plus-plus=no \
|
||||
--without-perl \
|
||||
--with-xml=yes \
|
||||
--with-png=yes \
|
||||
--with-jpeg=yes \
|
||||
--with-webp=yes \
|
||||
--host=$HOST && \
|
||||
make
|
||||
|
||||
USER root
|
||||
|
||||
RUN \
|
||||
make install && \
|
||||
ldconfig /usr/local/lib
|
||||
|
||||
|
||||
# Environment for Rust
|
||||
FROM cross-build as rust
|
||||
|
||||
RUN \
|
||||
apt-get install -y curl
|
||||
|
||||
ENV \
|
||||
PATH=$PATH:/opt/build/.cargo/bin
|
||||
|
||||
ADD --chown=build:build https://sh.rustup.rs /opt/build/rustup.sh
|
||||
|
||||
USER build
|
||||
|
||||
RUN \
|
||||
chmod +x rustup.sh && \
|
||||
./rustup.sh --default-toolchain $TOOLCHAIN --profile minimal -y && \
|
||||
rustup target add $TARGET
|
||||
|
||||
USER root
|
||||
|
||||
|
||||
# Environment for pict-rs
|
||||
FROM cross-build as pict-rs-builder
|
||||
|
||||
RUN \
|
||||
apt-get install -y \
|
||||
libgexiv2-dev:$ARCH \
|
||||
libxml2:$ARCH \
|
||||
libltdl7:$ARCH \
|
||||
llvm-dev \
|
||||
libclang-dev \
|
||||
clang \
|
||||
libpng16-16:$ARCH \
|
||||
libjpeg8:$ARCH \
|
||||
libwebp6:$ARCH \
|
||||
libwebpdemux2:$ARCH \
|
||||
libwebpmux3:$ARCH \
|
||||
libgomp1:$ARCH \
|
||||
libavcodec-dev:$ARCH \
|
||||
libavfilter-dev:$ARCH \
|
||||
libavdevice-dev:$ARCH \
|
||||
libavformat-dev:$ARCH \
|
||||
libavresample-dev:$ARCH \
|
||||
libavutil-dev:$ARCH \
|
||||
libswscale-dev:$ARCH \
|
||||
libswresample-dev:$ARCH \
|
||||
ffmpeg && \
|
||||
rm -rf /usr/include/x86_64-linux-gnu
|
||||
|
||||
ENV \
|
||||
PATH=$PATH:/opt/build/.cargo/bin \
|
||||
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig \
|
||||
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib \
|
||||
LD_RUN_PATH=$LD_RUN_PATH:/usr/local/lib \
|
||||
LDFLAGS="$LDFLAGS -L/usr/local/lib" \
|
||||
IMAGE_MAGICK_LIB_DIRS=/usr/local/lib \
|
||||
IMAGE_MAGICK_INCLUDE_DIRS=/usr/local/include/ImageMagick-7 \
|
||||
CFLAGS="$CFLAGS -I/usr/local/include/ImageMagick-7" \
|
||||
CPPFLAGS="$CPPFLAGS -I/usr/local/include/ImageMagick-7" \
|
||||
RUSTFLAGS="-L/usr/lib/$TOOL -C link-arg=-Wl,-rpath-link,/usr/lib/$TOOL -L/usr/$TOOL/lib -C link-arg=-Wl,-rpath-link,/usr/$TOOL/lib"
|
||||
|
||||
COPY --from=rust --chown=build:build /opt/build/.cargo /opt/build/.cargo
|
||||
COPY --from=rust --chown=build:build /opt/build/.rustup /opt/build/.rustup
|
||||
COPY --from=imagemagick-builder /usr/local/ /usr/local
|
||||
COPY root/ /
|
||||
|
||||
USER build
|
||||
|
||||
RUN \
|
||||
mkdir -p /opt/build/repo
|
||||
|
||||
WORKDIR /opt/build/repo
|
169
docker/dev/Dockerfile.arm64v8
Normal file
169
docker/dev/Dockerfile.arm64v8
Normal file
|
@ -0,0 +1,169 @@
|
|||
# Basic cross-build environment
|
||||
FROM ubuntu:20.04 as cross-build
|
||||
|
||||
ARG UID=1000
|
||||
ARG GID=1000
|
||||
|
||||
ENV \
|
||||
ARCH=arm64 \
|
||||
HOST=aarch64-unknown-linux \
|
||||
TOOL=aarch64-linux-gnu \
|
||||
TARGET=aarch64-unknown-linux-gnu \
|
||||
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
|
||||
CC_AARCH64_UNKNOWN_LINUX_GNU=aarch64-linux-gnu-gcc \
|
||||
CXX_AARCH64_UNKNOWN_LINUX_GNU=aarch64-linux-gnu-g++ \
|
||||
BUILD_MODE=release
|
||||
|
||||
ENV \
|
||||
TOOLCHAIN=stable \
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
PKG_CONFIG_ALLOW_CROSS=1 \
|
||||
PKG_CONFIG_PATH=/usr/lib/$TOOL/pkgconfig:/usr/lib/pkgconfig \
|
||||
LD_LIBRARY_PATH=/usr/lib/$TOOL:/usr/$TOOL/lib \
|
||||
LD_RUN_PATH=/usr/lib/$TOOL:/usr/$TOOL/lib \
|
||||
LDFLAGS="-L/usr/lib/$TOOL -L/usr/$TOOL/lib -Wl,-rpath-link,/usr/lib/$TOOL -Wl,-rpath-link,/usr/$TOOL/lib" \
|
||||
CFLAGS="-I/usr/include/$TOOL -I/usr/$TOOL/include -I/usr/include" \
|
||||
CPPFLAGS="-I/usr/include/$TOOL -I/usr/$TOOL/include -I/usr/include"
|
||||
|
||||
RUN \
|
||||
sed 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch-=amd64,i386] http:\/\/ports.ubuntu.com\/ubuntu-ports\//g' /etc/apt/sources.list > /etc/apt/sources.list.d/ports.list && \
|
||||
sed -i 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch=amd64,i386] http:\/\/\1.archive.ubuntu.com\/ubuntu\//g' /etc/apt/sources.list && \
|
||||
addgroup --gid $GID build && \
|
||||
adduser \
|
||||
--disabled-password \
|
||||
--gecos "" \
|
||||
--ingroup build \
|
||||
--uid $UID \
|
||||
--home /opt/build \
|
||||
build && \
|
||||
dpkg --add-architecture $ARCH && \
|
||||
apt-get update && \
|
||||
apt-get upgrade -y && \
|
||||
apt-get install -y \
|
||||
pkg-config \
|
||||
build-essential \
|
||||
crossbuild-essential-$ARCH
|
||||
|
||||
WORKDIR /opt/build
|
||||
|
||||
|
||||
# Environment for ImageMagick
|
||||
FROM cross-build as imagemagick-builder
|
||||
|
||||
RUN \
|
||||
apt-get install -y \
|
||||
libltdl-dev:$ARCH \
|
||||
libjpeg-dev:$ARCH \
|
||||
libpng-dev:$ARCH \
|
||||
libwebp-dev:$ARCH \
|
||||
liblzma-dev:$ARCH \
|
||||
libxml2-dev:$ARCH
|
||||
|
||||
ADD --chown=build:build https://imagemagick.org/download/ImageMagick.tar.gz /opt/build/ImageMagick.tar.gz
|
||||
|
||||
USER build
|
||||
|
||||
RUN \
|
||||
tar zxf ImageMagick.tar.gz && \
|
||||
mv ImageMagick-* ImageMagick
|
||||
|
||||
WORKDIR /opt/build/ImageMagick
|
||||
|
||||
RUN \
|
||||
./configure \
|
||||
CC=$TOOL-gcc \
|
||||
CXX=$TOOL-g++ \
|
||||
--enable-shared \
|
||||
--with-modules \
|
||||
--disable-static \
|
||||
--disable-docs \
|
||||
--prefix=/usr/local \
|
||||
--with-utilities=no \
|
||||
--with-magick-plus-plus=no \
|
||||
--without-perl \
|
||||
--with-xml=yes \
|
||||
--with-png=yes \
|
||||
--with-jpeg=yes \
|
||||
--with-webp=yes \
|
||||
--host=$HOST && \
|
||||
make
|
||||
|
||||
USER root
|
||||
|
||||
RUN \
|
||||
make install && \
|
||||
ldconfig /usr/local/lib
|
||||
|
||||
|
||||
# Environment for Rust
|
||||
FROM cross-build as rust
|
||||
|
||||
RUN \
|
||||
apt-get install -y curl
|
||||
|
||||
ENV \
|
||||
PATH=$PATH:/opt/build/.cargo/bin
|
||||
|
||||
ADD --chown=build:build https://sh.rustup.rs /opt/build/rustup.sh
|
||||
|
||||
USER build
|
||||
|
||||
RUN \
|
||||
chmod +x rustup.sh && \
|
||||
./rustup.sh --default-toolchain $TOOLCHAIN --profile minimal -y && \
|
||||
rustup target add $TARGET
|
||||
|
||||
USER root
|
||||
|
||||
|
||||
# Environment for pict-rs
|
||||
FROM cross-build as pict-rs-builder
|
||||
|
||||
RUN \
|
||||
apt-get install -y \
|
||||
libgexiv2-dev:$ARCH \
|
||||
libxml2:$ARCH \
|
||||
libltdl7:$ARCH \
|
||||
llvm-dev \
|
||||
libclang-dev \
|
||||
clang \
|
||||
libpng16-16:$ARCH \
|
||||
libjpeg8:$ARCH \
|
||||
libwebp6:$ARCH \
|
||||
libwebpdemux2:$ARCH \
|
||||
libwebpmux3:$ARCH \
|
||||
libgomp1:$ARCH \
|
||||
libavcodec-dev:$ARCH \
|
||||
libavfilter-dev:$ARCH \
|
||||
libavdevice-dev:$ARCH \
|
||||
libavformat-dev:$ARCH \
|
||||
libavresample-dev:$ARCH \
|
||||
libavutil-dev:$ARCH \
|
||||
libswscale-dev:$ARCH \
|
||||
libswresample-dev:$ARCH \
|
||||
ffmpeg && \
|
||||
rm -rf /usr/include/x86_64-linux-gnu
|
||||
|
||||
ENV \
|
||||
PATH=$PATH:/opt/build/.cargo/bin \
|
||||
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig \
|
||||
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib \
|
||||
LD_RUN_PATH=$LD_RUN_PATH:/usr/local/lib \
|
||||
LDFLAGS="$LDFLAGS -L/usr/local/lib" \
|
||||
IMAGE_MAGICK_LIB_DIRS=/usr/local/lib \
|
||||
IMAGE_MAGICK_INCLUDE_DIRS=/usr/local/include/ImageMagick-7 \
|
||||
CFLAGS="$CFLAGS -I/usr/local/include/ImageMagick-7" \
|
||||
CPPFLAGS="$CPPFLAGS -I/usr/local/include/ImageMagick-7" \
|
||||
RUSTFLAGS="-L/usr/lib/$TOOL -C link-arg=-Wl,-rpath-link,/usr/lib/$TOOL -L/usr/$TOOL/lib -C link-arg=-Wl,-rpath-link,/usr/$TOOL/lib"
|
||||
|
||||
COPY --from=rust --chown=build:build /opt/build/.cargo /opt/build/.cargo
|
||||
COPY --from=rust --chown=build:build /opt/build/.rustup /opt/build/.rustup
|
||||
COPY --from=imagemagick-builder /usr/local/ /usr/local
|
||||
COPY root/ /
|
||||
|
||||
USER build
|
||||
|
||||
RUN \
|
||||
mkdir -p /opt/build/repo
|
||||
|
||||
WORKDIR /opt/build/repo
|
|
@ -1,9 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ARCH=${1:-amd64}
|
||||
|
||||
export USER_ID=$(id -u)
|
||||
export GROUP_ID=$(id -g)
|
||||
|
||||
mkdir -p ./volumes/pictrs
|
||||
|
||||
docker-compose build --pull
|
||||
docker-compose run --service-ports pictrs
|
||||
docker-compose run --service-ports pictrs-$ARCH
|
||||
|
|
|
@ -1,10 +1,42 @@
|
|||
version: '3.3'
|
||||
|
||||
services:
|
||||
pictrs:
|
||||
build:
|
||||
pictrs-amd64:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
dockerfile: Dockerfile.amd64
|
||||
args:
|
||||
UID: "${USER_ID:-1000}"
|
||||
GID: "${GROUP_ID:-1000}"
|
||||
ports:
|
||||
- "8080:8080"
|
||||
stdin_open: true
|
||||
tty: true
|
||||
environment:
|
||||
- RUST_LOG=info,pict_rs=debug
|
||||
volumes:
|
||||
- ../../:/opt/build/repo
|
||||
|
||||
pictrs-arm64v8:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.arm64v8
|
||||
args:
|
||||
UID: "${USER_ID:-1000}"
|
||||
GID: "${GROUP_ID:-1000}"
|
||||
ports:
|
||||
- "8080:8080"
|
||||
stdin_open: true
|
||||
tty: true
|
||||
environment:
|
||||
- RUST_LOG=info,pict_rs=debug
|
||||
volumes:
|
||||
- ../../:/opt/build/repo
|
||||
|
||||
pictrs-arm32v7:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.arm32v7
|
||||
args:
|
||||
UID: "${USER_ID:-1000}"
|
||||
GID: "${GROUP_ID:-1000}"
|
||||
|
|
4
docker/dev/root/usr/bin/build
Executable file
4
docker/dev/root/usr/bin/build
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
shift
|
||||
cargo build --target=$TARGET
|
4
docker/dev/root/usr/bin/run
Executable file
4
docker/dev/root/usr/bin/run
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
shift
|
||||
cargo run --target=$TARGET -- "$@"
|
Loading…
Reference in a new issue