Skip to content

Commit

Permalink
Build Github release using Ubuntu 16.04 Docker image #624 (#642)
Browse files Browse the repository at this point in the history
* Try to build on Linux using ubuntu:xenial-20151218.1 based docker image.

* Map cargo dependencies cache to host dir.

* Fix docker run.

* Run tests in docker.

* Build Linux binary using xenial image for Github release only.

* Try to use host user and workdir avoid various permission and different paths issues.

* Set HOME=/root and explicitly set cargo env.

* Use target-xenial path in Dockerfile.release.

* Release on mm2 branch only again.
  • Loading branch information
artemii235 authored May 19, 2020
1 parent b1b4c23 commit 51dc0a7
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.release
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:bionic
WORKDIR /mm2
COPY target/release/mm2 /app/mm2
COPY target-xenial/release/mm2 /app/mm2
EXPOSE 7783
ENV PATH="/app:${PATH}"
CMD mm2
26 changes: 26 additions & 0 deletions Dockerfile.ubuntu.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM ubuntu:xenial-20151218.1

RUN \
apt-get update &&\
apt-get install -y git build-essential libssl-dev wget &&\
apt-get install -y cmake &&\
# https://github.com/rust-lang/rust-bindgen/blob/master/book/src/requirements.md#debian-based-linuxes
apt-get install -y llvm-3.9-dev libclang-3.9-dev clang-3.9 &&\
# openssl-sys requirements, cf. https://crates.io/crates/openssl-sys
apt-get install -y pkg-config libssl-dev &&\
apt-get clean

RUN \
wget -O- https://sh.rustup.rs > /tmp/rustup-init.sh &&\
sh /tmp/rustup-init.sh -y --default-toolchain none &&\
. /root/.cargo/env &&\
rustup set profile minimal &&\
rustup install nightly-2020-02-01 &&\
rustup default nightly-2020-02-01 &&\
# It seems that bindgen won't prettify without it:
rustup component add rustfmt-preview &&\
rm -f /tmp/rustup-init.sh &&\
chmod -R 777 /root

ENV PATH="/root/.cargo/bin:${PATH}"
WORKDIR /mm2
46 changes: 39 additions & 7 deletions azure-pipelines-release-stage-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,27 @@ jobs:
echo 2.0.$(Build.BuildId)_$(Build.SourceBranchName)_$(COMMIT_HASH)_$(Agent.OS)_Debug > MM_VERSION
cat MM_VERSION
touch mm2src/common/build.rs
cargo build --features native -vv
if [ $AGENT_OS = "Linux" ]
then
docker build -f Dockerfile.ubuntu.ci -t mm2_builder .
export UID=$(id -u)
export GID=$(id -g)
docker run \
--user $UID:$GID \
-v /home/azureagent/docker-cargo-cache/git:/root/.cargo/git \
-v /home/azureagent/docker-cargo-cache/registry:/root/.cargo/registry \
-v $PWD:$PWD \
-w $PWD \
-e HOME=/root \
mm2_builder \
/bin/bash -c "source /root/.cargo/env && cargo build --features native -vv --target-dir target-xenial"
else
cargo build --features native -vv
fi
displayName: 'Build MM2 Debug'
condition: eq( variables['DEBUG_UPLOADED'], '' )
- bash: |
zip upload/mm2-$(COMMIT_HASH)-$(Agent.OS)-Debug target/debug/mm2 -j
zip upload/mm2-$(COMMIT_HASH)-$(Agent.OS)-Debug target-xenial/debug/mm2 -j
displayName: 'Prepare debug build upload Linux'
condition: and( eq( variables['Agent.OS'], 'Linux' ), eq( variables['DEBUG_UPLOADED'], '' ) )
- bash: |
Expand All @@ -69,14 +85,30 @@ jobs:
echo 2.0.$(Build.BuildId)_$(Build.SourceBranchName)_$(COMMIT_HASH)_$(Agent.OS)_Release > MM_VERSION
cat MM_VERSION
touch mm2src/common/build.rs
cargo build --features native --release -vv
if [ $AGENT_OS = "Linux" ]
then
docker build -f Dockerfile.ubuntu.ci -t mm2_builder .
export UID=$(id -u)
export GID=$(id -g)
docker run \
--user $UID:$GID \
-v /home/azureagent/docker-cargo-cache/git:/root/.cargo/git \
-v /home/azureagent/docker-cargo-cache/registry:/root/.cargo/registry \
-v $PWD:$PWD \
-w $PWD \
-e HOME=/root \
mm2_builder \
/bin/bash -c "source /root/.cargo/env && cargo build --features native --release -vv --target-dir target-xenial"
else
cargo build --features native --release -vv
fi
displayName: 'Build MM2 Release'
condition: eq( variables['RELEASE_UPLOADED'], '' )
- bash: |
objcopy --only-keep-debug target/release/mm2 target/release/mm2.debug
strip -g target/release/mm2
zip upload/mm2-$(COMMIT_HASH)-$(Agent.OS)-Release target/release/mm2 -j
zip upload/mm2-$(COMMIT_HASH)-$(Agent.OS)-Release-debuginfo.zip target/release/mm2.debug -j
objcopy --only-keep-debug target-xenial/release/mm2 target-xenial/release/mm2.debug
strip -g target-xenial/release/mm2
zip upload/mm2-$(COMMIT_HASH)-$(Agent.OS)-Release target-xenial/release/mm2 -j
zip upload/mm2-$(COMMIT_HASH)-$(Agent.OS)-Release-debuginfo.zip target-xenial/release/mm2.debug -j
displayName: 'Prepare release build upload Linux'
condition: and( eq( variables['Agent.OS'], 'Linux' ), eq( variables['RELEASE_UPLOADED'], '' ) )
- bash: |
Expand Down

0 comments on commit 51dc0a7

Please sign in to comment.