-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored build to separate browser and electron and added docker bu…
…ild for main (#74) * Created Dockerfile based on theia-ide dockerfile setup and adjusted for CrossModel. * Updated package configurations and webpack configuration. * Added docker job to main workflow. * Updated all @crossbreeze package versions to 0.0.0 and updated versionspec where used. * Added installing unzip and unzip the vsix to the plugins folder. * Change crossmodel-lang to version 0.0.0. * Remove prepare script everywhere. * Made separate build & watch scripts for browser and electron, in line with start. * Updated build-and-test action to use build:browser. * Updated README.
- Loading branch information
Showing
21 changed files
with
328 additions
and
56 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
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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Stage 1: Builder stage | ||
FROM node:20-alpine AS build-stage | ||
|
||
# Install OS packages needed for building Theia. | ||
# Packages can be searched here: https://pkgs.alpinelinux.org/packages | ||
RUN apk add \ | ||
yarn \ | ||
libsecret-dev \ | ||
libxkbfile-dev \ | ||
make \ | ||
g++ \ | ||
python3 \ | ||
py3-setuptools \ | ||
unzip | ||
|
||
# Set the working directory | ||
WORKDIR /home/crossmodel | ||
|
||
# Copy the current directory contents to the container | ||
COPY . . | ||
|
||
# Run the build commands. | ||
# - Download plugins and build application | ||
# - Use yarn autoclean to remove unnecessary files from package dependencies | ||
# - Remove unnecesarry files for the browser application | ||
RUN yarn --pure-lockfile --skip-integrity-check --network-timeout 100000 && \ | ||
yarn build:packages && \ | ||
yarn build:extensions && \ | ||
yarn package:extensions && \ | ||
yarn theia:browser build && \ | ||
unzip extensions/crossmodel-lang/*.vsix -d applications/browser-app/plugins/crossmodel-lang && \ | ||
yarn autoclean --init && \ | ||
echo *.ts >> .yarnclean && \ | ||
echo *.ts.map >> .yarnclean && \ | ||
echo *.spec.* >> .yarnclean && \ | ||
yarn autoclean --force && \ | ||
yarn cache clean && \ | ||
rm -rf .devcontainer .git .github .vscode applications/electron-app docs e2e-tests examples | ||
|
||
# Stage 2: Production stage, using a slim image | ||
FROM node:20-alpine AS production-stage | ||
|
||
# Create a non-root user with a fixed user id and setup the environment | ||
RUN addgroup -S crossmodel && \ | ||
adduser --system --uid 101 crossmodel crossmodel && \ | ||
chmod g+rw /home && \ | ||
mkdir -p /home/crossmodel && \ | ||
chown -R crossmodel:crossmodel /home/crossmodel && \ | ||
mkdir -p /home/project | ||
|
||
# Install required tools for application: Git, SSH, Bash | ||
# Node is already available in base image | ||
RUN apk add \ | ||
bash \ | ||
openssh-server \ | ||
openssh-client-default \ | ||
libsecret \ | ||
git | ||
|
||
# Copy the mapping example workspace into the project folder. | ||
COPY examples/mapping-example /home/project | ||
|
||
# Set the permission of the project folder. | ||
RUN chown -R crossmodel:crossmodel /home/project | ||
|
||
ENV HOME=/home/crossmodel | ||
WORKDIR /home/crossmodel | ||
|
||
# Copy the build output to the production environment | ||
COPY --from=build-stage --chown=crossmodel:crossmodel /home/crossmodel /home/crossmodel | ||
|
||
# Expose the default CrossModel port | ||
EXPOSE 3000 | ||
|
||
# Specify default shell for Theia and the Built-In plugins directory | ||
# Use installed git instead of dugite | ||
ENV SHELL=/bin/bash \ | ||
THEIA_DEFAULT_PLUGINS=local-dir:/home/crossmodel/applications/browser-app/plugins \ | ||
USE_LOCAL_GIT=true | ||
|
||
# Use the non-root user | ||
USER crossmodel | ||
|
||
# Set the working directory to the browser application | ||
WORKDIR /home/crossmodel/applications/browser-app | ||
|
||
# Start the application | ||
ENTRYPOINT ["node", "/home/crossmodel/applications/browser-app/lib/backend/main.js"] | ||
|
||
# Arguments passed to the application | ||
CMD ["/home/project", "--hostname=0.0.0.0"] |
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,91 @@ | ||
# Stage 1: Builder stage | ||
FROM node:20-bookworm AS build-stage | ||
|
||
# Install OS packages needed for building Theia. | ||
RUN apt-get update && \ | ||
export DEBIAN_FRONTEND=noninteractive && \ | ||
apt-get -y install --no-install-recommends \ | ||
libsecret-1-dev \ | ||
libxkbfile-dev \ | ||
make \ | ||
build-essential \ | ||
python3 \ | ||
unzip | ||
|
||
# Set the working directory | ||
WORKDIR /home/crossmodel | ||
|
||
# Copy the current directory contents to the container | ||
COPY . . | ||
|
||
# Run the build commands. | ||
# - Download plugins and build application | ||
# - Use yarn autoclean to remove unnecessary files from package dependencies | ||
# - Remove unnecesarry files for the browser application | ||
RUN yarn --pure-lockfile --skip-integrity-check --network-timeout 100000 && \ | ||
yarn build:packages && \ | ||
yarn build:extensions && \ | ||
yarn package:extensions && \ | ||
yarn theia:browser build && \ | ||
unzip extensions/crossmodel-lang/*.vsix -d applications/browser-app/plugins/crossmodel-lang && \ | ||
yarn autoclean --init && \ | ||
echo *.ts >> .yarnclean && \ | ||
echo *.ts.map >> .yarnclean && \ | ||
echo *.spec.* >> .yarnclean && \ | ||
yarn autoclean --force && \ | ||
yarn cache clean && \ | ||
rm -rf .devcontainer .git .github .vscode applications/electron-app docs e2e-tests examples | ||
|
||
# Stage 2: Production stage, using a slim image | ||
FROM node:20-bookworm-slim AS production-stage | ||
|
||
# Create a non-root user with a fixed user id and setup the environment | ||
# Default workspace is located at /home/project | ||
RUN adduser --system --group --uid 101 --home /home/crossmodel crossmodel && \ | ||
chmod g+rw /home && \ | ||
chown -R crossmodel:crossmodel /home/crossmodel && \ | ||
mkdir -p /home/project | ||
|
||
# Install required tools for application: Git, SSH, Bash | ||
# Node is already available in base image | ||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
bash \ | ||
openssh-server \ | ||
openssh-client \ | ||
libsecret-1-0 \ | ||
git && \ | ||
apt-get clean | ||
|
||
# Copy the mapping example workspace into the project folder. | ||
COPY examples/mapping-example /home/project | ||
|
||
# Set the permission of the project folder. | ||
RUN chown -R crossmodel:crossmodel /home/project | ||
|
||
ENV HOME=/home/crossmodel | ||
WORKDIR /home/crossmodel | ||
|
||
# Copy the build output to the production environment | ||
COPY --from=build-stage --chown=crossmodel:crossmodel /home/crossmodel /home/crossmodel | ||
|
||
# Expose the default CrossModel port | ||
EXPOSE 3000 | ||
|
||
# Specify default shell for Theia and the Built-In plugins directory | ||
# Use installed git instead of dugite | ||
ENV SHELL=/bin/bash \ | ||
THEIA_DEFAULT_PLUGINS=local-dir:/home/crossmodel/applications/browser-app/plugins \ | ||
USE_LOCAL_GIT=true | ||
|
||
# Use the non-root user | ||
USER crossmodel | ||
|
||
# Set the working directory to the browser application | ||
WORKDIR /home/crossmodel/applications/browser-app | ||
|
||
# Start the application | ||
ENTRYPOINT ["node", "/home/crossmodel/applications/browser-app/lib/backend/main.js"] | ||
|
||
# Arguments passed to the application | ||
CMD ["/home/project", "--hostname=0.0.0.0"] |
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
Binary file not shown.
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
Oops, something went wrong.