diff --git a/devops/containers/sfdx-vlocity/Dockerfile b/devops/containers/sfdx-vlocity/Dockerfile new file mode 100644 index 00000000..3993670c --- /dev/null +++ b/devops/containers/sfdx-vlocity/Dockerfile @@ -0,0 +1,82 @@ +# base image +FROM node:14 + +# copy folders +COPY node-packages/ node-packages/ +COPY sfdx-plugins/ sfdx-plugins/ + +## pre install env variables +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true +ENV SFDX_HIDE_RELEASE_NOTES=true + +# install packages from http://deb.debian.org +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + gnupg \ + apt-utils \ + apt-transport-https \ + curl \ + wget \ + openssh-client \ + ca-certificates \ + jq \ + bc \ + gettext \ + xmlstarlet \ + bash \ + python3 \ + libxml2 \ + libxml2-utils \ + wget \ + openjdk-11-jre \ + && wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg \ + && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ + && curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + google-chrome-stable \ + fonts-ipafont-gothic \ + fonts-wqy-zenhei \ + fonts-thai-tlwg \ + fonts-kacst \ + fonts-freefont-ttf \ + libxss1 \ + gh \ + && rm -rf /var/lib/apt/lists/* + +# install packages from https://registry.npmjs.org +WORKDIR /node-packages +RUN cat ./package.json | jq '.devDependencies | keys[] as $k | "\($k)@\(.[$k])"' | xargs -t npm install --global + +# install sfdx plugins from https://registry.npmjs.org +WORKDIR /sfdx-plugins +RUN chmod +x sfdx-plugins-installer.sh && ./sfdx-plugins-installer.sh + +## post install env variables +ENV JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64" +ENV PATH="$PATH:$JAVA_HOME/bin" +ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome +ENV SFDX_AUTOUPDATE_DISABLE=false +ENV SFDX_JSON_TO_STDOUT=true +ENV SFDX_USE_GENERIC_UNIX_KEYCHAIN=true +ENV SFDX_DOMAIN_RETRY=true +ENV SFDX_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_CREATE=true +ENV SFDX_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE=true +ENV SFDX_DISABLE_DNS_CHECK=true +ENV SHELL=/bin/bash + +# tests +RUN java --version \ + && tsc -v \ + && sfdx --version \ + && sf --version \ + && sfdx plugins --core \ + && vlocity -v \ + && sfdx sgd -h \ + && gh --version + +# clean +RUN rm -f ~/.npmrc \ + && rm -rf /node-packages \ + && rm -rf /sfdx-plugins \ No newline at end of file diff --git a/devops/containers/sfdx-vlocity/README.md b/devops/containers/sfdx-vlocity/README.md new file mode 100644 index 00000000..1199bd85 --- /dev/null +++ b/devops/containers/sfdx-vlocity/README.md @@ -0,0 +1,43 @@ +# sfdx-vlocity + +This docker image bundles all the dependencies needed for developing Vlocity Applications for Salesforce. + +Developers can use this image to: + +- run CI automations. +- create cloud or local development environments using docker containers. + +## Dependencies + +- Openjdk 11 +- Node 14 +- sfdx cli +- vlocity cli + +### SFDX plugins + +- sfdx-git-delta + +## How to build + +```shell +docker build --platform linux/amd64 --no-cache --progress plain . +``` + +## Tools to setup Development Environments using Containers + +### Local + +- [Docker Desktop](https://www.docker.com/products/docker-desktop/). + +or Visual Studio Code|Github [`devcontainer.json`](https://containers.dev/implementors/json_reference/) files. + +- [devcontainers cli](https://github.com/devcontainers/cli). + +- Visual Studio Code extension called [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). + +### Cloud + +- [Codespaces](https://github.com/features/codespaces) + +- [Gitpod](https://www.gitpod.io/) diff --git a/devops/containers/sfdx-vlocity/node-packages/package.json b/devops/containers/sfdx-vlocity/node-packages/package.json new file mode 100644 index 00000000..317b3564 --- /dev/null +++ b/devops/containers/sfdx-vlocity/node-packages/package.json @@ -0,0 +1,12 @@ +{ + "name": "global-dependencies", + "version": "1.0.0", + "description": "This package controls global npm dependencies", + "devDependencies": { + "typescript": "4.9.5", + "@salesforce/cli": "1.67.1", + "sfdx-cli": "7.188.1", + "vlocity": "1.17.0", + "puppeteer": "19.7.2" + } +} diff --git a/devops/containers/sfdx-vlocity/sfdx-plugins/package.json b/devops/containers/sfdx-vlocity/sfdx-plugins/package.json new file mode 100644 index 00000000..e6e92619 --- /dev/null +++ b/devops/containers/sfdx-vlocity/sfdx-plugins/package.json @@ -0,0 +1,8 @@ +{ + "name": "sfdx-plugins", + "version": "1.0.0", + "description": "This package controls sfdx plugins", + "devDependencies": { + "sfdx-git-delta": "5.13.3" + } +} diff --git a/devops/containers/sfdx-vlocity/sfdx-plugins/sfdx-plugins-installer.sh b/devops/containers/sfdx-vlocity/sfdx-plugins/sfdx-plugins-installer.sh new file mode 100755 index 00000000..6f0ba915 --- /dev/null +++ b/devops/containers/sfdx-vlocity/sfdx-plugins/sfdx-plugins-installer.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +for row in $(cat package.json | jq -c '.devDependencies | to_entries | .[]'); do + name=$(echo $row | jq -r '.key') + # sfdx plugins:install does not work with ~ and ^ https://github.com/forcedotcom/cli/issues/1966 + version=$(echo $row | jq -r '.value' | cut -d "~" -f2 | cut -d "^" -f2) + echo "Installing $name@$version" + echo 'y' | sfdx plugins:install $name@$version +done \ No newline at end of file