Skip to content
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

Fix build error for multi-arch Docker images #1

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 0 additions & 87 deletions .github/workflows/build-docker-slim.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: build-docker-full
name: build-docker
on:
workflow_call:
inputs:
version:
type: string
description: The release semver version
required: true
required: false
default: latest
channel:
type: string
description: The release channel (latest-rc, nightly, dev, etc)
Expand All @@ -24,14 +25,14 @@ jobs:
node-version: ${{ vars.NODE_VERSION_OVERRIDE || 'lts/*' }}

- name: Log in to Docker Hub
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
uses: docker/metadata-action@v5
with:
images: salesforce/cli

Expand All @@ -51,12 +52,12 @@ jobs:
STEPS_SETUP_NODE_NODE_VERSION: ${{ steps.setup-node.outputs.node-version }}

- name: Build and push Docker image
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25
uses: docker/build-push-action@v5
with:
context: .
push: true
labels: ${{ steps.meta.outputs.labels }}
file: dockerfiles/Dockerfile_full
file: Dockerfile
build-args: |
NODE_VERSION=${{ steps.setup-node.outputs.node-version }}
NODE_CHECKSUM=${{ steps.node-checksum.outputs.sha }}
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/test-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: test-docker
on:
push:
branches:
- docker/**

jobs:
buildPush:
runs-on: ubuntu-latest
if: github.event.repository.fork
steps:
- name: Check out the repo
uses: actions/checkout@v4

- uses: actions/setup-node@v4
id: setup-node
with:
node-version: ${{ vars.NODE_VERSION_OVERRIDE || 'lts/*' }}

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: salesforce/cli

- name: Collect Node checksum
id: node-checksum
run: |
NODE_VERSION="$STEPS_SETUP_NODE_NODE_VERSION"

URL="https://nodejs.org/dist/$NODE_VERSION/SHASUMS256.txt"
echo "Retrieving SHA data from: $URL"

SHA=$(curl -s "$URL" | awk "/[0-9a-f]{64} node-$NODE_VERSION-linux-x64.tar.gz/ { print \$1 }")
echo "Checksum found: $SHA"

echo "sha=$SHA" >> "$GITHUB_OUTPUT"
env:
STEPS_SETUP_NODE_NODE_VERSION: ${{ steps.setup-node.outputs.node-version }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile
build-args: |
NODE_VERSION=${{ steps.setup-node.outputs.node-version }}
NODE_CHECKSUM=${{ steps.node-checksum.outputs.sha }}
SF_CLI_VERSION=${{ inputs.version || 'latest' }}
tags: salesforce/cli:${{ inputs.channel }}-full, salesforce/cli:${{ inputs.version || 'latest' }}-full

verify:
needs: buildPush
runs-on: ubuntu-latest
container:
image: salesforce/cli:${{ inputs.version || 'latest' }}-full
steps:
- name: verify node, sf, jq
# without bash this will fail. Not sure what the default shell is but it doesn't like the [[(())]] bashism
shell: bash
run: |
set -e
node -v
sf version --verbose
jq --help
NODE_VERSION=$(sf version --verbose --json | jq '.nodeVersion')
SF_CLI_VERSION=$(sf version --verbose --json | jq '.cliVersion')
if [[ ((`echo $SF_CLI_VERSION | grep -c "@salesforce/cli/"` > 0))]]
then
echo "sf installed -" $SF_CLI_VERSION
else
echo "The sf installation could not be verified"
exit 1
fi
if [[ ((`echo $NODE_VERSION | grep -c "v"` > 0))]]
then
echo "node installed -" $NODE_VERSION
else
echo "The node installation could not be verified"
exit 1
fi
33 changes: 33 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Contributing to Salesforce CLI

Thank you for your interest in contributing to Salesforce CLI! We welcome contributions from the community and are excited to work with you.

## Getting Started

1. Fork the repository on GitHub.
2. Clone your forked repository to your local machine.
3. Create a new branch for your contribution.
4. Make your changes and commit them with a clear and concise commit message.
5. Push your changes to your forked repository.
6. Open a pull request against the main repository.

## Testing Docker Build Workflows

We have introduced a new capability for contributors to test the Docker build workflows in their forks. You can now create a branch starting with `docker/` to trigger the test Docker build workflow. This workflow will run on all pushes in forks and publish to the local package registry in the repository.

### Steps to Test Docker Build Workflows

1. Create a new branch in your forked repository with a name starting with `docker/`.
2. Make your changes to the Dockerfile or related workflows.
3. Push your changes to the `docker/` branch.
4. The test Docker build workflow will automatically run and publish the Docker images to the local package registry in the repository.

## Code of Conduct

Please note that this project is governed by the Salesforce Code of Conduct. By participating, you are expected to adhere to this code. Please report any unacceptable behavior to [[email protected]](mailto:[email protected]).

## License

By contributing to Salesforce CLI, you agree that your contributions will be licensed under the [BSD 3-Clause License](LICENSE.txt).

Thank you for contributing to Salesforce CLI!
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM heroku/heroku:22

ENV DEBIAN_FRONTEND=noninteractive

# This will typically be nightly
ARG SF_CLI_VERSION=nightly
# Full semver version with `v` prefix. e.g. v20.9.0
ARG NODE_VERSION
# sha256 checksum for the nodejs.tar.gz file
ARG NODE_CHECKSUM

RUN echo "${NODE_CHECKSUM} ./nodejs.tar.gz" > node-file-lock.sha \
&& curl -s -o nodejs.tar.gz https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64.tar.gz \
&& shasum --check node-file-lock.sha
RUN mkdir /usr/local/lib/nodejs \
&& tar xf nodejs.tar.gz -C /usr/local/lib/nodejs/ --strip-components 1 \
&& rm nodejs.tar.gz node-file-lock.sha

ENV PATH=/usr/local/lib/nodejs/bin:$PATH
RUN npm install --global @salesforce/cli@${SF_CLI_VERSION}

RUN apt-get update && apt-get install --assume-yes openjdk-11-jdk-headless jq
RUN apt-get autoremove --assume-yes \
&& apt-get clean --assume-yes \
&& rm -rf /var/lib/apt/lists/*

ENV SF_CONTAINER_MODE true
ENV SFDX_CONTAINER_MODE true
ENV DEBIAN_FRONTEND=dialog
ENV SHELL /bin/bash

# Add QEMU installation step to enable multi-arch support
RUN apt-get update && apt-get install -y qemu-user-static

# Add --platform flag to docker build command to specify target architectures
# This is typically done in the build command, not in the Dockerfile itself
# Example: docker buildx build --platform linux/amd64,linux/arm64 -t myimage:latest .

# Update SF_CLI_VERSION argument to use the latest version by default
ARG SF_CLI_VERSION=latest
10 changes: 10 additions & 0 deletions dockerfiles/Dockerfile_full
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ ENV SF_CONTAINER_MODE true
ENV SFDX_CONTAINER_MODE true
ENV DEBIAN_FRONTEND=dialog
ENV SHELL /bin/bash

# Add QEMU installation step to enable multi-arch support
RUN apt-get update && apt-get install -y qemu-user-static

# Add --platform flag to docker build command to specify target architectures
# This is typically done in the build command, not in the Dockerfile itself
# Example: docker buildx build --platform linux/amd64,linux/arm64 -t myimage:latest .

# Update SF_CLI_VERSION argument to use the latest version by default
ARG SF_CLI_VERSION=latest
10 changes: 10 additions & 0 deletions dockerfiles/Dockerfile_slim
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,13 @@ ENV SF_CONTAINER_MODE true
ENV SFDX_CONTAINER_MODE true
ENV DEBIAN_FRONTEND=dialog
ENV SHELL /bin/bash

# Add QEMU installation step to enable multi-arch support
RUN apt-get update && apt-get install -y qemu-user-static

# Add --platform flag to docker build command to specify target architectures
# This is typically done in the build command, not in the Dockerfile itself
# Example: docker buildx build --platform linux/amd64,linux/arm64 -t myimage:latest .

# Update DOWNLOAD_URL argument to use the latest version by default
ARG DOWNLOAD_URL=https://developer.salesforce.com/media/salesforce-cli/sf/channels/latest/sf-linux-x64.tar.xz
Loading