-
Notifications
You must be signed in to change notification settings - Fork 377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added environment variables to control the UID and GID in the container #543
Conversation
I'm not sure of others would find this useful, but I ran into this when trying to setup a github-action that would cross-compile binaries for me and commit them back to the repo. The trickiest part was probably getting docker to work but is then what lead me to this PR since I had to use docker-machine. ---
name: CI+CD
on:
push:
branches:
- main
jobs:
crate_universe:
runs-on: macos-10.15
steps:
- uses: actions/checkout@v2
with:
# Save the git credentials so we can commit back to the repo
persist-credentials: true
- run: |
# Install docker for use with cross
# https://medium.com/crowdbotics/a-complete-one-by-one-guide-to-install-docker-on-your-mac-os-using-homebrew-e818eb4cfc3
brew install docker docker-machine boot2docker boot2docker-cli
- run: |
# Configure docker-machine
docker-machine create --driver virtualbox --virtualbox-boot2docker-url https://github.com/boot2docker/boot2docker/releases/download/v19.03.12/boot2docker.iso default
# For some reason, `sed -r 's/export (.*)="(.*)"/\1=\2/'` does not work because `-r` is not a valid option for sed
docker-machine env default | grep "export" | sed 's/export //' | sed 's/"//' | sed 's/"//' >> $GITHUB_ENV
echo "COMPOSE_INTERACTIVE_NO_CLI=0" >> $GITHUB_ENV
- run: |
# Confirm docker is runnable
docker --version
# Ensure docker works and volumes are able to be used to write back to the host
docker run --rm -v "${HOME}:/root" alpine touch /root/hello-from-docker
rm ~/hello-from-docker
- run: |
# Install cross
#curl -Lo ~/cross.tar.gz https://github.com/rust-embedded/cross/releases/download/v0.2.1/cross-v0.2.1-x86_64-apple-darwin.tar.gz
#tar -xf ~/cross.tar.gz -C /usr/local/bin/
#chmod +x /usr/local/bin/cross
# Install a version that solves for https://github.com/rust-embedded/cross/pull/543
cargo install --git https://github.com/rust-embedded/cross.git --branch master
echo "CROSS_CONTAINER_UID=1000" > $GITHUB_ENV
cross --version
- run: |
# Install host toolchains
rustup update stable && rustup default stable
- run: |
# Setup macos build tooling
sudo xcode-select -s /Applications/Xcode_12.4.app/Contents/Developer/
# Set SDK environment variables
echo "SDKROOT=$(xcrun -sdk macosx11.1 --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.1 --show-sdk-platform-version)" >> $GITHUB_ENV
- run: |
# Build all binaries
./bootstrap.sh
- run: |
# Stage and display the changes
git stage -A . && git status
- run: |
# Setup git and commit back to the repo
git config user.email "[email protected]"
git config user.name "uebel_andre"
git commit -m 'github-actions: auto-updated binaries'
git push origin For more context on the level of complexity in this action around setting up docker, see actions/runner-images#115 |
@Dylan-DPC Hey, do you have a quick moment to take a look at this? 🙏 |
bors: r+ |
Build succeeded: |
@Dylan-DPC Would it be possible to get a new release with this commit as well? |
@UebelAndre unfortunately I don't have permissions for that and someone else would have to do it |
@UebelAndre, I did manage to run docker on GH actions using vagrant. but I get this error.
It seems like the the |
I'm not familiar with the error you ran into. I ended up doing exactly what you see in #543 (comment) and successfully built my project using cross. You might need some steps like - run: |
# Install host toolchains
rustup update stable && rustup default stable But I'm no expert here. My recommendation is to use what I wrote since I was able to confirm it works for simple use cases. |
Thank you, will try that |
@UebelAndre sorry for pinging you again. Did you encounter any Full log: https://github.com/david-allison-1/Anki-Android-Backend/runs/2244327761
|
I did not, everything ran quite smoothly for me. Though, I think related to another issue, I had to |
CROSS_CONTAINER_UID
andCROSS_CONTAINER_GID
can now be used to control the user and group ID's passed to Docker.I ran into this when trying to setup a Github-Action that runs on MacOS and uses docker-machine which wasn't working. I then found #389 which described the solution of updating the UID and GID which I've confirmed works. This change should make it easier for users to solve for the same issue without making a fork.