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

Add Docker Image #572

Merged
merged 17 commits into from
Mar 21, 2023
Merged
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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN npm install --global pkg-fetch
RUN pkg-fetch -n node16 -p linux -a x64
RUN pkg-fetch -n node16 -p macos -a x64

RUN npm install --global pkg@4.3.8
RUN npm install --global pkg

# declare /vlocity_build as working directory of image
WORKDIR /vlocity_build
Expand All @@ -24,4 +24,4 @@ RUN npm install

# Important to do this final part last because of how docker builds image
# copy all remaining files/folders in project directory to the container
COPY . /vlocity_build
COPY . /vlocity_build
82 changes: 82 additions & 0 deletions devops/containers/sfdx-vlocity/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions devops/containers/sfdx-vlocity/README.md
Original file line number Diff line number Diff line change
@@ -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/)
12 changes: 12 additions & 0 deletions devops/containers/sfdx-vlocity/node-packages/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
8 changes: 8 additions & 0 deletions devops/containers/sfdx-vlocity/sfdx-plugins/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "sfdx-plugins",
"version": "1.0.0",
"description": "This package controls sfdx plugins",
"devDependencies": {
"sfdx-git-delta": "5.13.3"
}
}
Original file line number Diff line number Diff line change
@@ -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