Cross-platform compilation all working.
This commit is contained in:
parent
f5fbb85ed5
commit
e6ed77dd78
@ -1,11 +1,14 @@
|
||||
FROM alpine:latest
|
||||
FROM debian:bullseye AS builder
|
||||
|
||||
RUN apk add --no-cache \
|
||||
build-base \
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
cmake \
|
||||
pkgconfig \
|
||||
pkg-config \
|
||||
bash \
|
||||
musl-dev
|
||||
gcc-aarch64-linux-gnu \
|
||||
g++-aarch64-linux-gnu \
|
||||
binutils-aarch64-linux-gnu \
|
||||
qemu-user-static
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@ -16,6 +19,6 @@ COPY --chmod=755 docker/dropshell_alpine/_create_dropshell.sh /scripts/
|
||||
RUN rm -rf build
|
||||
|
||||
ENV CXXFLAGS="-static-libstdc++ -static-libgcc"
|
||||
ENV LDFLAGS="-static"
|
||||
ENV LDFLAGS="-static -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive"
|
||||
|
||||
CMD ["/bin/bash","/scripts/_create_dropshell.sh"]
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM alpine:latest
|
||||
FROM --platform=$BUILDPLATFORM alpine:latest AS builder
|
||||
|
||||
RUN apk add --no-cache \
|
||||
bash \
|
||||
@ -11,6 +11,18 @@ RUN /bin/bash -c "mkdir -p /opt/dropshell/templates && mkdir -p /config"
|
||||
COPY templates /opt/dropshell/templates
|
||||
COPY src/dropshell-completion.bash /etc/bash_completion.d/
|
||||
|
||||
FROM alpine:latest
|
||||
|
||||
RUN apk add --no-cache \
|
||||
bash \
|
||||
nano
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/dropshell /app/dropshell
|
||||
COPY --from=builder /opt/dropshell/templates /opt/dropshell/templates
|
||||
COPY --from=builder /etc/bash_completion.d/dropshell-completion.bash /etc/bash_completion.d/
|
||||
|
||||
RUN /app/dropshell init /config
|
||||
RUN /app/dropshell version
|
||||
|
||||
|
@ -8,5 +8,3 @@ make -j4
|
||||
cp /app/build/dropshell /output/
|
||||
|
||||
chown $CHOWN_USER:$CHOWN_GROUP /output/dropshell
|
||||
|
||||
/app/build/dropshell version
|
||||
|
@ -6,6 +6,7 @@ ROOT_DIR=$(dirname $(dirname $SCRIPT_DIR))
|
||||
|
||||
echo "Building dropshell from $ROOT_DIR"
|
||||
|
||||
# Build the builder image
|
||||
docker build -t dropshell_alpine_builder $ROOT_DIR -f $SCRIPT_DIR/Dockerfile.build
|
||||
|
||||
rm -rf $SCRIPT_DIR/output
|
||||
@ -14,10 +15,33 @@ mkdir -p $SCRIPT_DIR/output
|
||||
MYUID=$(id -u)
|
||||
MYGID=$(id -g)
|
||||
|
||||
docker run -it --env CHOWN_USER=$MYUID --env CHOWN_GROUP=$MYGID -v $SCRIPT_DIR/output:/output dropshell_alpine_builder
|
||||
# Build for x86_64
|
||||
echo "Building for x86_64..."
|
||||
docker run --rm -tt --env CHOWN_USER=$MYUID --env CHOWN_GROUP=$MYGID \
|
||||
-v $SCRIPT_DIR/output:/output \
|
||||
-e TARGET_ARCH=x86_64 \
|
||||
-e CC=gcc \
|
||||
-e CXX=g++ \
|
||||
dropshell_alpine_builder
|
||||
|
||||
echo "dropshell built in $SCRIPT_DIR/output/dropshell"
|
||||
mv $SCRIPT_DIR/output/dropshell $SCRIPT_DIR/output/dropshell_x86_64
|
||||
|
||||
docker build -t gitea.jde.nz/j/dropshell_alpine:latest -t dropshell_alpine $ROOT_DIR -f $SCRIPT_DIR/Dockerfile.run
|
||||
$SCRIPT_DIR/output/dropshell_x86_64 version
|
||||
|
||||
echo "dropshell built in $SCRIPT_DIR/output/dropshell_x86_64"
|
||||
|
||||
|
||||
# Build for arm64
|
||||
echo "Building for arm64..."
|
||||
docker run --rm -tt --env CHOWN_USER=$MYUID --env CHOWN_GROUP=$MYGID \
|
||||
-v $SCRIPT_DIR/output:/output \
|
||||
-e TARGET_ARCH=aarch64 \
|
||||
-e CC=aarch64-linux-gnu-gcc \
|
||||
-e CXX=aarch64-linux-gnu-g++ \
|
||||
dropshell_alpine_builder
|
||||
|
||||
mv $SCRIPT_DIR/output/dropshell $SCRIPT_DIR/output/dropshell_aarch64
|
||||
|
||||
|
||||
echo "dropshell built in $SCRIPT_DIR/output/dropshell_aarch64"
|
||||
|
||||
docker run -it dropshell_alpine version
|
||||
|
BIN
docker/dropshell_alpine/output/dropshell_aarch64
Executable file
BIN
docker/dropshell_alpine/output/dropshell_aarch64
Executable file
Binary file not shown.
BIN
docker/dropshell_alpine/output/dropshell_x86_64
Executable file
BIN
docker/dropshell_alpine/output/dropshell_x86_64
Executable file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user