forked from MetaMask/metamask-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Fix CocoaPods install on Linux (MetaMask#9545)
- Enable `pod install` step in `yarn setup` script on all platforms - Failing installation is still only treated as actual failure on macOS - Apply `react-native` patch that resolves installation error due to attempt at patching missing Xcode - Upstream PR: facebook/react-native#44417 - Add developer `Dockerfile` which can be used locally to run routine development tasks like `yarn setup`. - Add CI job that builds docker image and tests it with metamask-mobile - In order for the new job to run, the newly used actions must be enabled in repository settings.
Showing
6 changed files
with
166 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: docker | ||
on: | ||
push: | ||
branches: main | ||
pull_request: | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- uses: actions/checkout@v3 | ||
|
||
- name: Build and load | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: scripts/docker/Dockerfile | ||
# test with nonstandard uid and gid | ||
build-args: | | ||
UID=1234 | ||
GID=1235 | ||
load: true | ||
tags: metamask-mobile-builder:latest | ||
# could enable push to gh registry | ||
push: false | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Test yarn setup | ||
run: | | ||
sudo chown -R 1234:1235 . | ||
docker run \ | ||
--rm \ | ||
-v "$(pwd):/app" -w /app \ | ||
metamask-mobile-builder:latest \ | ||
bash -c 'yarn && yarn setup --build-ios' | ||
# restore ownership for cleanup | ||
sudo chown -R "$(id -u):$(id -g)" . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# syntax=docker/dockerfile:1.4 | ||
FROM node:20-bookworm | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
git curl jq time \ | ||
sudo locales \ | ||
build-essential ccache cmake cmake-format distcc \ | ||
&& sed -i '/en_US.UTF-8/s/^# //' /etc/locale.gen \ | ||
&& locale-gen | ||
|
||
ENV YARN_VERSION 1.22.22 | ||
# replace base image yarn 1.19 | ||
# checksums and sigs for 1.22 not available as of now... | ||
# https://github.com/nodejs/docker-node/blob/07bd7414c9eeb7a134951122e1105e8c849f770e/Dockerfile-debian.template | ||
COPY scripts/docker/yarn-v$YARN_VERSION.tar.gz.sha256 . | ||
RUN curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ | ||
&& sha256sum yarn-v$YARN_VERSION.tar.gz.sha256 \ | ||
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ | ||
&& ln -sf /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ | ||
&& ln -sf /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ | ||
&& rm yarn-v$YARN_VERSION.tar.gz.sha256 yarn-v$YARN_VERSION.tar.gz \ | ||
&& yarn --version | ||
|
||
ARG UID=1000 | ||
ARG GID=1000 | ||
# if UID differs from default: create new user/group; take over /home/node | ||
RUN bash -c "[ ${GID} != \"1000\" ] && groupadd -g ${GID} -U node userz || true" \ | ||
&& bash -c "[ ${UID} != \"1000\" ] && useradd -u ${UID} -g ${GID} -d /home/node user && chown -R ${UID}:${GID} /home/node || true" \ | ||
&& usermod -G sudo -a $(id -un ${UID}) \ | ||
&& echo '%sudo ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers | ||
|
||
# install ruby deps | ||
COPY --chown=${UID}:${GID} Gemfile* .ruby-version /tmp/app/ | ||
WORKDIR /tmp/app | ||
|
||
#### | ||
USER $UID:$GID | ||
ENV BUNDLE_PATH=/home/node/.bundle | ||
ENV HOME=/home/node | ||
# distro rbenv and ruby are out of date - install rbenv from git and manage ruby | ||
# RUBY_BUILD_VERSION=v20240501 | ||
ARG RBENV_COMMIT=c3ba994ec2daccf4d160aea7f55dd5cc6fc873ef | ||
ARG RUBY_BUILD_COMMIT=263640c9fe1d44e6fc8f86fc56a67ee58e7b22f7 | ||
RUN (mkdir /home/node/.rbenv \ | ||
&& curl -sL https://github.com/rbenv/rbenv/archive/${RBENV_COMMIT}.tar.gz \ | ||
| tar --strip-components=1 -C /home/node/.rbenv/ -xzf - \ | ||
) && (mkdir -p /home/node/.rbenv/plugins/ruby-build \ | ||
&& curl -sL https://github.com/rbenv/ruby-build/archive/${RUBY_BUILD_COMMIT}.tar.gz \ | ||
| tar --strip-components=1 -C /home/node/.rbenv/plugins/ruby-build -xzf - \ | ||
) \ | ||
&& echo 'eval "$(/home/node/.rbenv/bin/rbenv init -)"' >> /home/node/.bashrc | ||
|
||
RUN bash -c 'eval "$(/home/node/.rbenv/bin/rbenv init -)" \ | ||
&& rbenv install \ | ||
&& gem install bundler -v 2.5.8 \ | ||
&& gem install bigdecimal cocoapods \ | ||
&& bundle install' | ||
|
||
# fix broken ipv6 on nodejs v20 | ||
env NODE_OPTIONS="--no-network-family-autoselection --trace-warnings" | ||
env PATH=/home/node/.rbenv/shims/:$PATH | ||
|
||
WORKDIR /app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
The Dockerfile in this directory is intended for local dev. | ||
|
||
It has a `docker.io/node` debian base, with MetaMask Mobile build dependencies installed and sudo for the default user enabled. | ||
|
||
## Using | ||
### Building | ||
``` | ||
$ docker buildx build --pull --build-arg UID=$(id -u) --build-arg GID=$(id -g) -t mm-mobile-build:debian -f scripts/docker/Dockerfile . | ||
``` | ||
|
||
### Running | ||
``` | ||
$ docker run --rm -it \ | ||
-u $(id -u) \ | ||
-v "$(pwd)":/app -w /app \ | ||
mm-mobile-build:debian \ | ||
/bin/bash | ||
# To reuse host yarn cache | ||
$ docker run --rm -it \ | ||
-u $(id -u) \ | ||
-v "$(pwd)":/app -w /app \ | ||
-v ~/.cache/yarn:/home/node/.cache/yarn \ | ||
mm-mobile-build:debian \ | ||
/bin/bash | ||
# shell inside container | ||
$ yarn setup --build-ios | ||
``` | ||
|
||
### Filesystem permissions | ||
Building the image locally maps the default user UID and GID to the `UID` and `GID` build-args (default `1000`). This means that when you run and mount the image with your local git repository with the same owner, permissions will map semlessly. | ||
You may need to adjust the `--build-arg UID=` and `--build-arg GID=` flags in the following cases: | ||
|
||
- The UID/GID of the user running the image is different from the one building it | ||
- You are running rootless docker or podman | ||
- You are getting filesystem permission errors when running the image | ||
- You are using some exotic container runtime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
88268464199d1611fcf73ce9c0a6c4d44c7d5363682720d8506f6508addf36a0 yarn-v1.22.22.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters