Skip to content

Commit

Permalink
Updated alpine dockerfile and changed default to alpine.
Browse files Browse the repository at this point in the history
  • Loading branch information
harmen-xb committed Nov 22, 2024
1 parent 81ad694 commit 7d0e586
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 81 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cicd-feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ env:
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-test:
uses: ./.github/workflows/build-and-test.yml
#build-and-test:
# uses: ./.github/workflows/build-and-test.yml

docker:
runs-on: ubuntu-latest
Expand Down
48 changes: 24 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Stage 1: Builder stage
FROM node:20-bookworm AS build-stage
FROM node:20-alpine 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 \
python3 \
build-essential \
unzip
# 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
Expand All @@ -37,25 +38,24 @@ RUN yarn --pure-lockfile --skip-integrity-check --network-timeout 100000 && \
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
FROM node:20-alpine 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 && \
RUN addgroup -S crossmodel && \
adduser --system --uid 101 crossmodel crossmodel && \
chmod g+rw /home && \
mkdir -p /home/project && \
chown -R crossmodel:crossmodel /home/crossmodel
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 apt-get update && \
apt-get install -y \
git \
openssh-client \
openssh-server \
bash \
libsecret-1-0 && \
apt-get clean
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
Expand Down Expand Up @@ -88,4 +88,4 @@ WORKDIR /home/crossmodel/applications/browser-app
ENTRYPOINT ["node", "/home/crossmodel/applications/browser-app/lib/backend/main.js"]

# Arguments passed to the application
CMD [ "/home/project", "--hostname=0.0.0.0"]
CMD ["/home/project", "--hostname=0.0.0.0"]
55 changes: 0 additions & 55 deletions Dockerfile.alpine

This file was deleted.

91 changes: 91 additions & 0 deletions Dockerfile.ubuntu
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"]

0 comments on commit 7d0e586

Please sign in to comment.