-
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.
Updated alpine dockerfile and changed default to alpine.
- Loading branch information
Showing
4 changed files
with
117 additions
and
81 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 was deleted.
Oops, something went wrong.
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"] |