Giter Club home page Giter Club logo

docker-for-ios-osx-bitbucket-pipelines's Introduction

Docker for iOS/OSX Bitbucket pipelines

dockeri.co

Introduction

Bitbucket Pipelines doesn't support iOS/OSX builds. This simple Docker image tries to solve this by connecting to:

Pull Docker Image

docker pull felhr85/docker-for-ios-bitbucket-pipelines:1.0.0

What do we need to add in out project?

The next files need to be added to the root of your Bitbucket project.

  • Bitbucket pipelines standard yaml file.
  • A config file (config.json) with configuration information.
  • AWS config and credentials (aws_config and aws_credentials) files if necessary.
  • A run.sh script that contains our build commands.
  • A post_run.sh script for downloading whatever we need from the finished build process.
  • A ssh key if using Aws.

Example using AWS

The first step is to create a new Mac OSX instance in EC2. And we add to the project our aws credentials and the ssh key we will use.

aws_config

[default]
region = us-east-2
output = json

aws_config

[default]
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

Next we add a config.json file as follows

{
    "instance_id" : "i-017f8354e2dc69c4f",
    "remote_repo": "~",
    "instance_user" : "ec2-user",
    "ssh_port" : 22,
    "ssh_key" : "test-key.pem",
    "script" : "run.sh",
    "post_script" : "post_run.sh"
}

We need to define what compile actions we want to perform and what files we want to bring back to our docker instance. That's done in both run.sh and post_run.sh scripts respectively.

run.sh

#!/bin/bash
xcodebuild -scheme Example build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED="NO" CONFIGURATION_BUILD_DIR=./outputs/
exit $?

post_run.sh

#!/bin/bash
#---- These variables need to be here
USER=$1
IP=$2
PORT=$3
SSH_KEY=$4
BITBUCKET_REPO=$5
REMOTE_REPO=$6
IP=$7
PASSWORD=$8
#-----

mkdir -p build
scp -o StrictHostKeyChecking=no -P ${PORT} -i /tmp/${SSH_KEY} -r ${USER}@${IP}:${REMOTE_REPO}/outputs/ .
exit $?

Finally we need a bitbucket_pipelines.yml

steps:
  - step: &build_ios
      name: Build iOS
      image: felhr85/docker-for-ios-bitbucket-pipelines:latest
      script:
        - bash pipelines_aws.sh 
pipelines:
  branches:
    master:
      - step: *build_ios    

Example using OSX with remote Login

First, enable remote login in your OSX machine

sudo systemsetup -f setremotelogin on

Next we add a config.json file as follows

{

    "ip": "172.158.12.54",
    "user": "my_user",
    "password": "my_password",
    "remote_repo": "~",
    "ssh_port" : 22,
    "script" : "run.sh",
    "post_script" : "post_run.sh"
}

We need to define what compile actions we want to perform and what files we want to bring back to our docker instance. That's done in both run.sh and post_run.sh scripts respectively.

run.sh

#!/bin/bash
xcodebuild -scheme Example build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED="NO" CONFIGURATION_BUILD_DIR=./outputs/
exit $?

post_run.sh

#!/bin/bash
#---- These variables need to be here
USER=$1
IP=$2
PORT=$3
SSH_KEY=$4
BITBUCKET_REPO=$5
REMOTE_REPO=$6
IP=$7
PASSWORD=$8
#-----

mkdir -p build
sshpass -p ${PASSWORD} scp -o StrictHostKeyChecking=no -P ${PORT} -r ${USER}@${IP}:${REMOTE_REPO}/outputs/ .
exit $?

Finally we need a bitbucket_pipelines.yml

steps:
  - step: &build_ios
      name: Build iOS
      image: felhr85/docker-for-ios-bitbucket-pipelines:latest
      script:
        - bash pipelines_server.sh 
pipelines:
  branches:
    master:
      - step: *build_ios    

docker-for-ios-osx-bitbucket-pipelines's People

Contributors

felhr85 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

singhmanav

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.