Skip to content

Commit

Permalink
Instructions to build and package Theia into a rpm for easy distribut…
Browse files Browse the repository at this point in the history
…ion. Tested and evaluated for CentOS/RH Linux 7. Older OS versions are not supported. For new version support, watch bbc/speculate#75

Signed-off-by: Joshua Bradley <[email protected]>
  • Loading branch information
jgbradley1 authored and dwjbosman committed Jul 24, 2019
1 parent 66e953b commit 7c6960a
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
34 changes: 34 additions & 0 deletions theia-rpm-build-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM centos:7
# install development tools
RUN curl --silent --location https://rpm.nodesource.com/setup_10.x | bash - && \
yum groupinstall -y "Development Tools" && \
yum install -y nodejs && \
npm install -g yarn

# required file to install Theia
COPY package.json run_theia.sh /theia-app/

# build theia
WORKDIR /theia-app
RUN yarn && \
NODE_OPTIONS="--max_old_space_size=4096" yarn theia build && \
yarn autoclean --init && \
echo *.ts >> .yarnclean && \
echo *.ts.map >> .yarnclean && \
echo *.spec.* >> .yarnclean && \
yarn autoclean --force && \
yarn cache clean

# create theia rpm
RUN npm run build-rpm

# transfer rpm to new clean image and demonstrate successful rpm install (yum will handle all rpm dependencies i.e. Node v10)
FROM centos:7
COPY --from=0 /root/rpmbuild/RPMS/x86_64/theia-0.0.1-1.x86_64.rpm /
RUN curl --silent --location https://rpm.nodesource.com/setup_10.x | bash - && \
yum install -y theia-0.0.1-1.x86_64.rpm && \
rm -f theia-0.0.1-1.x86_64.rpm

ENV SHELL /bin/bash
EXPOSE 3000
CMD ["theia","start","--hostname=0.0.0.0"]
18 changes: 18 additions & 0 deletions theia-rpm-build-docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Theia RPM Build
A demonstration of how to package the [Theia Cloud IDE](https://github.com/theia-ide/theia) into an RPM for easier distribution, using the [speculate](https://www.npmjs.com/package/speculate) module.

This example uses a [multi-stage build](https://docs.docker.com/develop/develop-images/multistage-build/) design to first build and package Theia into an rpm. The rpm is then transferred to a new image to preserve a clean environment. This process is independent of docker and could be replicated in other build environments (i.e. on localhost).

## Quickstart
```console
# build rpm
> git clone https://github.com/theia-ide/theia-apps.git
> cd theia-apps/theia-rpm-build-docker
> docker build -t theia-rpm .

# to verify RPM installation was successful
> docker run -p 3000:3000 -it theia-rpm bash
> theia --help # call Theia CLI directly
> theia start --hostname=0.0.0.0 # start Theia
```

50 changes: 50 additions & 0 deletions theia-rpm-build-docker/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "theia",
"version": "0.0.1",
"license": "EPL-2.0",
"engines" : {
"node":"10.x"
},
"dependencies": {
"@theia/callhierarchy": "latest",
"@theia/file-search": "latest",
"@theia/json": "latest",
"@theia/markers": "latest",
"@theia/merge-conflicts": "latest",
"@theia/messages": "latest",
"@theia/mini-browser": "latest",
"@theia/navigator": "latest",
"@theia/outline-view": "latest",
"@theia/preferences": "latest",
"@theia/preview": "latest",
"@theia/search-in-workspace": "latest",
"@theia/terminal": "latest",
"@theia/textmate-grammars": "latest",
"typescript": "latest"
},
"devDependencies": {
"@theia/cli": "latest"
},
"scripts": {
"prebuild": "npm install -g yarn",
"prebuild-rpm": "ln -s \"$( pwd )\" ~/rpmbuild && npm install -g speculate",
"build-rpm": "speculate && rpmbuild -bb SPECS/theia.spec",
"start": "npm run prebuild && yarn theia start"
},
"spec": {
"rebuild": false,
"prune": false,
"nodeVersion": "> 10.0.0",
"requires": [
"nodejs",
"python"
],
"executable": [
"./run_theia.sh"
],
"post": [
"mv /usr/lib/theia/run_theia.sh /usr/local/bin/theia"
]
}
}

5 changes: 5 additions & 0 deletions theia-rpm-build-docker/run_theia.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
\cd /usr/lib/theia
args=( $@ )
node src-gen/backend/main.js ${args[*]}

0 comments on commit 7c6960a

Please sign in to comment.