Skip to content

Commit

Permalink
docker: fix and improve docker example
Browse files Browse the repository at this point in the history
Before this commit the docker example was not properly building.
The issue was introduced when moving from Theia 1.3x to 1.4x, where
an extra step in the build process was introduced (i.e. running "yarn"
was not enough, an extra "theia" command was needed).

After this commit:
- the docker example is building again
- the docker image generated is stable and reproducible,
  not based on "next"
- the docker image is much smaller thanks to a multistage build

Signed-off-by: Francesco Robino <[email protected]>
  • Loading branch information
frallax committed Dec 8, 2023
1 parent ff0943f commit 2bdd27b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
46 changes: 33 additions & 13 deletions examples/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
FROM node:16-alpine
FROM node:16.20.2-bookworm-slim as build

RUN mkdir /home/app
WORKDIR /home/app

RUN apk add --no-cache bash git python3 make pkgconfig libsecret-dev g++
# Use "bash" as replacement for "sh"
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get update && apt-get install -y \
git \
python3 \
make \
pkg-config \
libsecret-1-dev \
g++ \
libx11-dev \
libxkbfile-dev

# Build the browser theia-trace-extension application
COPY example-package.json /home/app/package.json
RUN npx yarn
COPY example-package.json /app/tte/package.json
WORKDIR /app/tte/
RUN yarn && \
npx theia build --app-target=\"browser\" --mode development && \
yarn autoclean --init && \
echo *.ts >> .yarnclean && \
echo *.ts.map >> .yarnclean && \
echo *.spec.* >> .yarnclean && \
yarn cache clean

FROM node:16.20.2-bookworm-slim

COPY --from=build /app/tte /app/tte

COPY startup.sh /home/app
RUN ["chmod", "+x", "/home/app/startup.sh"]
RUN apt-get update && apt-get install -y \
libx11-6 \
libxkbfile1 \
libsecret-1-0 \
&& rm -rf /var/lib/apt/lists/*
ENV NODE_ENV production

# Start the service
ENTRYPOINT ["/home/app/startup.sh"]
WORKDIR /app/tte
COPY docker-entrypoint.sh /usr/local/bin
EXPOSE 4000
ENTRYPOINT ["docker-entrypoint.sh"]
2 changes: 2 additions & 0 deletions examples/docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
yarn start --hostname 0.0.0.0 --port 4000
8 changes: 5 additions & 3 deletions examples/docker/example-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
}
},
"dependencies": {
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@mui/material": "^5.10.14",
"@theia/core": "1.43.1",
"@theia/editor": "1.43.1",
"@theia/filesystem": "1.43.1",
Expand All @@ -27,12 +30,11 @@
"@theia/preferences": "1.43.1",
"@theia/process": "1.43.1",
"@theia/terminal": "1.43.1",
"@theia/vsx-registry": "1.43.1",
"@theia/workspace": "1.43.1",
"theia-traceviewer": "next"
"theia-traceviewer": "0.2.0-next.20231206220005.ff0943f.0"
},
"devDependencies": {
"@theia/cli": "1.43.1"
"@theia/cli": "1.40.1"
},
"scripts": {
"prepare": "theia build",
Expand Down
3 changes: 0 additions & 3 deletions examples/docker/startup.sh

This file was deleted.

0 comments on commit 2bdd27b

Please sign in to comment.