This Docker container provides a standalone CLI for interacting with a CodePush server, allowing you to easily release prebuilt React Native applications to a CodePush server instance.
This container wraps the Microsoft CodePush Server CLI tools to simplify the process of releasing updates to your applications using CodePush. It's designed to be used as part of a CI/CD pipeline or as a standalone tool for releasing updates.
- Docker installed on your system
- Access to a CodePush server instance
- An access key for your CodePush server
- Your application bundle prepared in a directory
To build the container image, run:
docker build -t codepush-cli:latest .The container is configured with several environment variables that control its behavior:
| Variable | Description | Default |
|---|---|---|
access_key |
Your CodePush server access key | "your-access-key" |
app_name |
The name of your application | "your-app" |
command |
The CodePush command to run | "release" |
server_url |
URL of your CodePush server | "https://appcenter.ms" |
target_version |
Target version of your app | "1.0.0" |
To release an update to your CodePush server, mount your application bundle directory to /data in the container and set the appropriate environment variables:
docker run --rm \
-v /path/to/your/app/bundle:/data \
-e access_key="your-access-key" \
-e app_name="YourApp" \
-e server_url="https://your-codepush-server.com" \
-e target_version="1.2.0" \
codepush-cli:latestBy default, the container runs the release command. You can specify a different command using the command environment variable:
docker run --rm \
-v /path/to/your/app/bundle:/data \
-e access_key="your-access-key" \
-e app_name="YourApp" \
-e command="promote" \
-e server_url="https://your-codepush-server.com" \
codepush-cli:latestThis container is ideal for integration with CI/CD pipelines. For example, with GitHub Actions:
steps:
- name: Release to CodePush
run: |
docker run --rm \
-v ${{ github.workspace }}/dist:/data \
-e access_key="${{ secrets.CODEPUSH_ACCESS_KEY }}" \
-e app_name="${{ env.APP_NAME }}" \
-e server_url="${{ env.CODEPUSH_SERVER_URL }}" \
-e target_version="${{ env.APP_VERSION }}" \
codepush-cli:latestIf you want to include this container as part of a CI/CD pipeline, you will need to make the container image accessible to the pipeline. This can be done by:
- Pushing the built container to a public container registry (like Docker Hub, GitHub Container Registry, etc.)
- Using a privately hosted build agent or runner where this image has either been pre-built
- Using a private container registry that your CI/CD system has access to pull from
Example of pushing to a container registry:
# Build and tag the image
docker build -t yourusername/codepush-cli:latest .
# Push to Docker Hub
docker push yourusername/codepush-cli:latest
# For GitHub Container Registry
docker build -t ghcr.io/yourusername/codepush-cli:latest .
docker push ghcr.io/yourusername/codepush-cli:latestThen update your CI/CD configuration to use the registry version:
steps:
- name: Release to CodePush
run: |
docker run --rm \
-v ${{ github.workspace }}/dist:/data \
-e access_key="${{ secrets.CODEPUSH_ACCESS_KEY }}" \
-e app_name="${{ env.APP_NAME }}" \
-e server_url="${{ env.CODEPUSH_SERVER_URL }}" \
-e target_version="${{ env.APP_VERSION }}" \
ghcr.io/yourusername/codepush-cli:latestIf you encounter permissions issues with the mounted volume, ensure that the directory you're mounting has appropriate permissions for the container's codepush user (UID 999).
If you're having trouble connecting to your CodePush server:
- Verify that the server URL is correct
- Check that your access key is valid
- Ensure your network allows connections to the server
This project is based on Microsoft's Code Push Server which is licensed under the MIT License.
Britehouse Mobility DevOps