forked from dxatscale/sfpowerscripts
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dockerfile): improve mechanism to build locally (#86)
enhance review process by having ability to build a docker image on commit id Co-authored-by: azlam <[email protected]>
- Loading branch information
1 parent
3fb6b01
commit ddcc19f
Showing
5 changed files
with
198 additions
and
13 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,41 @@ | ||
name: Build sfp Docker Image | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
commit_id: | ||
description: 'Commit ID to build and publish' | ||
required: true | ||
|
||
jobs: | ||
build-and-publish-docker: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.inputs.commit_id }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
tags: | | ||
ghcr.io/${{ github.repository }}/sfp:review | ||
build-args: | | ||
GIT_COMMIT==${{ github.event.inputs.commit_id }} | ||
SF_COMMIT_ID=${{ github.event.inputs.commit_id }} |
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 |
---|---|---|
@@ -1,16 +1,161 @@ | ||
FROM node:18 | ||
ARG SFP_URL=https://github.com/flxbl-io/sfp.git | ||
ARG SFP_COMMIT_ID=HEAD | ||
|
||
# Create app directory | ||
WORKDIR /usr/src/app | ||
|
||
FROM node:latest as node-build | ||
ARG SFP_URL | ||
ARG SFP_COMMIT_ID | ||
|
||
COPY package*.json ./ | ||
WORKDIR /app | ||
# Install necessary packages | ||
RUN apt-get update && \ | ||
apt-get install -y git | ||
|
||
RUN npm install | ||
# If you are building your code for production | ||
# RUN npm ci --omit=dev | ||
# Clone the repository | ||
RUN git clone ${SFP_URL} . && \ | ||
# Checkout the provided commit id | ||
git checkout ${SFP_COMMIT_ID} | ||
|
||
# Bundle app source | ||
COPY . . | ||
# Install dependencies and build | ||
RUN npm install && \ | ||
npm run build | ||
|
||
ENTRYPOINT ["./bin/run"] | ||
# List contents | ||
RUN ls -la /app | ||
|
||
|
||
|
||
|
||
FROM ubuntu:22.04 | ||
|
||
|
||
ARG SF_CLI_VERSION=2.46.6 | ||
ARG BROWSERFORCE_VERSION=4.0.0 | ||
ARG SFDMU_VERSION=4.32.2 | ||
ARG GIT_COMMIT | ||
ARG NODE_MAJOR=18 | ||
|
||
LABEL org.opencontainers.image.description "docker image for sfops with sf, sfp pro cli + gh cli installed" | ||
LABEL org.opencontainers.image.url "https://github.com/flxbl-io/sfops" | ||
LABEL org.opencontainers.image.documentation "https://docs.flxbl.io/sfops" | ||
LABEL org.opencontainers.image.revision $GIT_COMMIT | ||
LABEL org.opencontainers.image.vendor "Flxbl" | ||
|
||
|
||
|
||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
|
||
RUN ln -sf bash /bin/sh | ||
|
||
|
||
RUN apt-get update \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get -y install --no-install-recommends \ | ||
git \ | ||
curl \ | ||
sudo \ | ||
jq \ | ||
zip \ | ||
unzip \ | ||
make \ | ||
g++ \ | ||
tzdata \ | ||
openjdk-17-jre-headless \ | ||
ca-certificates \ | ||
libxkbcommon-x11-0 libdigest-sha-perl libxshmfence-dev \ | ||
gconf-service libappindicator1 libasound2 libatk1.0-0 \ | ||
libatk-bridge2.0-0 libcairo-gobject2 libdrm2 libgbm1 libgconf-2-4 \ | ||
libgtk-3-0 libnspr4 libnss3 libx11-xcb1 libxcb-dri3-0 libxcomposite1 libxcursor1 \ | ||
libxdamage1 libxfixes3 libxi6 libxinerama1 libxrandr2 libxshmfence1 libxss1 libxtst6 \ | ||
fonts-liberation fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf \ | ||
chromium-bsu \ | ||
chromium-driver \ | ||
gnupg \ | ||
&& apt-get autoremove --assume-yes \ | ||
&& apt-get clean --assume-yes \ | ||
&& rm -rf /var/lib/apt/list/* | ||
|
||
# Set timezone to UTC | ||
ENV TZ=UTC | ||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | ||
|
||
# install nodejs via nodesource | ||
RUN mkdir -p /etc/apt/keyrings \ | ||
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ | ||
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \ | ||
&& apt-get update \ | ||
&& apt-get -y install --no-install-recommends nodejs \ | ||
&& apt-get autoremove --assume-yes \ | ||
&& apt-get clean --assume-yes \ | ||
&& rm -rf /var/lib/apt/list/* | ||
|
||
# install yarn | ||
RUN npm install --global yarn --omit-dev \ | ||
&& npm cache clean --force | ||
|
||
# Install SF cli and sfp | ||
RUN npm install --global --omit=dev \ | ||
@salesforce/cli@${SF_CLI_VERSION} \ | ||
&& npm cache clean --force | ||
|
||
|
||
# Copy the built sfp cli from the previous stage | ||
RUN mkdir -p /app | ||
COPY --from=node-build /app/ /app/ | ||
RUN cd /app && npm link | ||
|
||
|
||
|
||
|
||
|
||
# Set XDG environment variables explicitly so that GitHub Actions does not apply | ||
# default paths that do not point to the plugins directory | ||
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html | ||
ENV XDG_DATA_HOME=/sf_plugins/.local/share \ | ||
XDG_CONFIG_HOME=/sf_plugins/.config \ | ||
XDG_CACHE_HOME=/sf_plugins/.cache \ | ||
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64/ \ | ||
PUPPETEER_CACHE_DIR=/root/.cache/puppeteer | ||
|
||
|
||
# Create symbolic link from sh to bash | ||
# Create isolated plugins directory with rwx permission for all users | ||
# Azure pipelines switches to a container-user which does not have access | ||
# to the root directory where plugins are normally installed | ||
RUN mkdir -p $XDG_DATA_HOME && \ | ||
mkdir -p $XDG_CONFIG_HOME && \ | ||
mkdir -p $XDG_CACHE_HOME && \ | ||
chmod -R 777 sf_plugins && \ | ||
export JAVA_HOME && \ | ||
export XDG_DATA_HOME && \ | ||
export XDG_CONFIG_HOME && \ | ||
export XDG_CACHE_HOME | ||
|
||
|
||
|
||
# Install sfdx plugins | ||
RUN echo 'y' | sf plugins:install sfdx-browserforce-plugin@${BROWSERFORCE_VERSION} \ | ||
&& echo 'y' | sf plugins:install sfdmu@${SFDMU_VERSION} \ | ||
&& echo 'y' | sf plugins:install @salesforce/[email protected] \ | ||
&& echo 'y' | sf plugins:install @salesforce/[email protected] \ | ||
&& yarn cache clean --all | ||
|
||
# Set some sane behaviour in container | ||
ENV SF_CONTAINER_MODE=true | ||
ENV SF_DISABLE_AUTOUPDATE=true | ||
ENV SF_DISABLE_TELEMETRY=true | ||
ENV SF_USE_GENERIC_UNIX_KEYCHAIN=true | ||
ENV SF_USE_PROGRESS_BAR=false | ||
ENV SF_DNS_TIMEOUT=60000 | ||
ENV SF_SKIP_VERSION_CHECK=true | ||
ENV SF_SKIP_NEW_VERSION_CHECK=true | ||
|
||
WORKDIR /root | ||
|
||
|
||
|
||
# clear the entrypoint for azure | ||
ENTRYPOINT [] | ||
CMD ["/bin/sh"] |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
FROM ubuntu:22.04 | ||
|
||
|
||
ARG SFPOWERSCRIPTS_VERSION=alpha | ||
|
||
ARG GIT_COMMIT | ||
ARG NODE_MAJOR=18 | ||
|
||
|
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