Skip to content

Commit

Permalink
Build containers with GHA
Browse files Browse the repository at this point in the history
- Increase clangd timeout to 150 minutes
  • Loading branch information
kaisalmen committed Sep 5, 2024
1 parent c06ba66 commit 5a9438b
Show file tree
Hide file tree
Showing 16 changed files with 255 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ indent_size = 2

[*.md]
indent_size = 2

[*.yml]
indent_size = 2
1 change: 1 addition & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build:
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/ls-clangd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Clangd LS Image

on:
workflow_dispatch:

env:
REGISTRY: ghcr.io
REPO_NAME: ${{ github.repository }}
PATH_CONTEXT: ./packages/examples/resources/clangd
CONTAINER_NAME_CONFIGURE: clangd-wasm-configure
CONTAINER_NAME_BUILD: clangd-wasm-build

jobs:
images-clangd-wasm:
name: Build & Deploy Clangd LS
runs-on: ubuntu-latest

permissions:
contents: read
packages: write
attestations: write
id-token: write

timeout-minutes: 150
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (configure)
id: meta_configure
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.REPO_NAME }}/${{ env.CONTAINER_NAME_CONFIGURE }}
# enforce latest tag for now
tags: |
type=raw,value=latest
- name: Build & Push (configure)
id: push_configure
uses: docker/build-push-action@v6
with:
context: ${{ env.PATH_CONTEXT }}
file: ${{ env.PATH_CONTEXT }}/configure.Dockerfile
push: true
tags: ${{ steps.meta_configure.outputs.tags }}
labels: ${{ steps.meta_configure.outputs.labels }}

- name: Attest (configure)
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/${{ env.CONTAINER_NAME_CONFIGURE }}
subject-digest: ${{ steps.push_configure.outputs.digest }}
push-to-registry: true

- name: Extract metadata (build)
id: meta_build
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.REPO_NAME }}/${{ env.CONTAINER_NAME_BUILD }}
# enforce latest tag for now
tags: |
type=raw,value=latest
- name: Build & Push (build)
id: push_build
uses: docker/build-push-action@v6
with:
context: ${{ env.PATH_CONTEXT }}
file: ${{ env.PATH_CONTEXT }}/build.Dockerfile
push: true
tags: ${{ steps.meta_build.outputs.tags }}
labels: ${{ steps.meta_build.outputs.labels }}

- name: Attest (build)
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/${{ env.CONTAINER_NAME_BUILD }}
subject-digest: ${{ steps.push_build.outputs.digest }}
push-to-registry: true
60 changes: 60 additions & 0 deletions .github/workflows/ls-eclipsejdt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Eclipse JDT LS Image

on:
workflow_dispatch:

env:
REGISTRY: ghcr.io
REPO_NAME: ${{ github.repository }}
PATH_CONTEXT: ./packages/examples/resources/eclipse.jdt.ls
CONTAINER_NAME: eclipse.jdt.ls

jobs:
image-eclipsejdtls:
name: Build & Deploy Eclipse JDT LS
runs-on: ubuntu-latest

permissions:
contents: read
packages: write
attestations: write
id-token: write

timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.REPO_NAME }}/${{ env.CONTAINER_NAME }}
# enforce latest tag for now
tags: |
type=raw,value=latest
- name: Build & Push
id: push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ env.PATH_CONTEXT }}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Attest
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/${{ env.CONTAINER_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
60 changes: 60 additions & 0 deletions .github/workflows/ls-groovy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Groovy LS Image

on:
workflow_dispatch:

env:
REGISTRY: ghcr.io
REPO_NAME: ${{ github.repository }}
PATH_CONTEXT: ./packages/examples/resources/groovy
CONTAINER_NAME: groovy.ls

jobs:
image-groovyls:
name: Build & Deploy Groovy LS
runs-on: ubuntu-latest

permissions:
contents: read
packages: write
attestations: write
id-token: write

timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.REPO_NAME }}/${{ env.CONTAINER_NAME }}
# enforce latest tag for now
tags: |
type=raw,value=latest
- name: Build & Push
id: push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ env.PATH_CONTEXT }}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Attest
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/${{ env.CONTAINER_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ npm run start:example:server:python

##### Groovy Language Server

For the **groovy-client** example you need to ensure the **groovy-server** example is running. You require **docker-compose** which does not require any manual setup (OpenJDK / Gradle). From the project root run `docker-compose -f ./packages/examples/resources/groovy/docker-compose.yml up -d`. First start up will take longer as the container is built. Use `docker-compose -f ./packages/examples/resources/groovy/docker-compose.yml down` to stop it.
For the **groovy-client** example you need to ensure the **groovy-server** example is running. You require **docker-compose** which does not require any manual setup (OpenJDK / Gradle). From the project root run `docker-compose -f ./packages/examples/resources/groovy/docker-compose.yml up -d`. First start up will take longer as the container is downloaded from GitHub's container registry. Use `docker-compose -f ./packages/examples/resources/groovy/docker-compose.yml down` to stop it.

##### Java Language Server

For the **java-client** example you need to ensure the **java-server** example is running. You require **docker-compose** which does not require any manual setup (OpenJDK / Eclipse JDT LS). From the project root run `docker-compose -f ./packages/examples/resources/eclipse.jdt.ls/docker-compose.yml up -d`. First start up will take longer as the container is built. Use `docker-compose -f ./packages/examples/resources/eclipse.jdt.ls/docker-compose.yml down` to stop it.
For the **java-client** example you need to ensure the **java-server** example is running. You require **docker-compose** which does not require any manual setup (OpenJDK / Eclipse JDT LS). From the project root run `docker-compose -f ./packages/examples/resources/eclipse.jdt.ls/docker-compose.yml up -d`. First start up will take longer as the container is downloaded from GitHub's container registry. Use `docker-compose -f ./packages/examples/resources/eclipse.jdt.ls/docker-compose.yml down` to stop it.

### Verification Examples & Usage

Expand Down
2 changes: 1 addition & 1 deletion packages/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"compile": "tsc --build tsconfig.src.json",
"resources:download": "vite-node ./build/downloadResources.mts",
"build:msg": "echo Building main examples:",
"build": "npm run build:msg && npm run clean && npm run resources:download && npm run compile",
"build": "npm run build:msg && npm run clean && npm run resources:download && npm run extract:docker && npm run compile",
"build:bundle": "vite --config vite.bundle.config.ts build",
"start:server:json": "vite-node src/json/server/direct.ts",
"start:server:python": "vite-node src/python/server/direct.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/examples/resources/clangd/build.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM clangd-clangd-configure
FROM ghcr.io/typefox/monaco-languageclient/clangd-wasm-configure:latest

COPY build-docker.sh /builder/build-docker.sh
COPY wait_stdin.patch /builder/wait_stdin.patch

RUN (cd /builder; ./build-docker.sh)
RUN (cd /builder; bash ./build-docker.sh)
5 changes: 3 additions & 2 deletions packages/examples/resources/clangd/build.docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
services:
clangd-build:
clangd-wasm-build:
image: ghcr.io/typefox/monaco-languageclient/clangd-wasm-build:latest
build:
dockerfile: ./build.Dockerfile
context: .
# only linux/amd64 for now
platforms:
- "linux/amd64"
platform: linux/amd64
container_name: clangd-build
container_name: clangd-wasm-build
2 changes: 1 addition & 1 deletion packages/examples/resources/clangd/configure.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ RUN volta install node \
RUN mkdir /builder

COPY configure-docker.sh /builder/configure-docker.sh
RUN (cd /builder; ./configure-docker.sh)
RUN (cd /builder; bash ./configure-docker.sh)
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
services:
clangd-configure:
clangd-wasm-configure:
image: ghcr.io/typefox/monaco-languageclient/clangd-wasm-configure:latest
build:
dockerfile: ./configure.Dockerfile
context: .
# only linux/amd64 for now
platforms:
- "linux/amd64"
platform: linux/amd64
container_name: clangd-configure
container_name: clangd-wasm-configure
29 changes: 17 additions & 12 deletions packages/examples/resources/clangd/scripts/extractDockerFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ import child_process from "node:child_process";

const outputDir = './resources/clangd/wasm';

// clean always
fs.rmSync(outputDir, {
force: true,
recursive: true
});
fs.mkdirSync(outputDir);
try {
child_process.execFileSync('docker', ['create', '--name', 'extract-clangd', 'ghcr.io/typefox/monaco-languageclient/clangd-wasm-build:latest']);

child_process.execFileSync('docker', ['create', '--name', 'extract-clangd', 'clangd-clangd-build']);
child_process.execFileSync('docker', ['cp', 'extract-clangd:/builder/llvm-project/build/bin/clangd.js', outputDir]);
child_process.execFileSync('docker', ['cp', 'extract-clangd:/builder/llvm-project/build/bin/clangd.wasm', outputDir]);
child_process.execFileSync('docker', ['cp', 'extract-clangd:/builder/llvm-project/build/bin/clangd.worker.js', outputDir]);
child_process.execFileSync('docker', ['cp', 'extract-clangd:/builder/llvm-project/build/bin/clangd.worker.mjs', outputDir]);
child_process.execFileSync('docker', ['rm', 'extract-clangd']);
// clean but only if container start was successful
fs.rmSync(outputDir, {
force: true,
recursive: true
});
fs.mkdirSync(outputDir);

child_process.execFileSync('docker', ['cp', 'extract-clangd:/builder/llvm-project/build/bin/clangd.js', outputDir]);
child_process.execFileSync('docker', ['cp', 'extract-clangd:/builder/llvm-project/build/bin/clangd.wasm', outputDir]);
child_process.execFileSync('docker', ['cp', 'extract-clangd:/builder/llvm-project/build/bin/clangd.worker.js', outputDir]);
child_process.execFileSync('docker', ['cp', 'extract-clangd:/builder/llvm-project/build/bin/clangd.worker.mjs', outputDir]);
child_process.execFileSync('docker', ['rm', 'extract-clangd']);
} catch (e) {
console.warn('Clangd wasm data was not extracted from container image!');
}
6 changes: 5 additions & 1 deletion packages/examples/resources/eclipse.jdt.ls/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ RUN mkdir -p ${PATH_MLC}
# copy repo content
COPY ./ ${PATH_MLC}

RUN cd ${PATH_MLC} \
&& npm i \
&& npm run build

# download and extract Eclipse JDT LS in target folder
RUN mkdir -p ${PATH_ECLIPSE_JDT} \
&& cd ${PATH_ECLIPSE_JDT} \
Expand All @@ -29,4 +33,4 @@ RUN mkdir -p ${PATH_ECLIPSE_JDT} \

WORKDIR ${PATH_MLC}

CMD ["/bin/bash", "npm i && npm run start:example:server:jdtls"]
CMD ["/bin/bash", "npm run start:example:server:jdtls"]
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
services:
eclipsejdtls:
image: ghcr.io/typefox/monaco-languageclient/eclipse.jdt.ls:latest
build:
dockerfile: ./packages/examples/resources/eclipse.jdt.ls/Dockerfile
context: ../../../..
Expand All @@ -10,7 +11,7 @@ services:
# - "linux/arm64"
platform: linux/amd64
command: [
"bash", "-c", "npm i && npm run start:example:server:jdtls"
"bash", "-c", "npm run start:example:server:jdtls"
]
ports:
- 30003:30003
Expand Down
6 changes: 5 additions & 1 deletion packages/examples/resources/groovy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ RUN cd ${HOME_DIR} \
# copy repo content
COPY ./ ${PATH_MLC}

RUN cd ${PATH_MLC} \
&& npm i \
&& npm run build

# copy language server to target
RUN mkdir -p ${PATH_GROOVY_JAR} \
&& cp ${PATH_GLS}/build/libs/groovy-language-server-all.jar ${PATH_GROOVY_JAR}

WORKDIR ${PATH_MLC}

CMD ["/bin/bash", "npm i && npm run start:example:server:groovy"]
CMD ["/bin/bash", "npm run start:example:server:groovy"]
3 changes: 2 additions & 1 deletion packages/examples/resources/groovy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
services:
groovyls:
image: ghcr.io/typefox/monaco-languageclient/groovy.ls:latest
build:
dockerfile: ./packages/examples/resources/groovy/Dockerfile
context: ../../../..
Expand All @@ -10,7 +11,7 @@ services:
# - "linux/arm64"
platform: linux/amd64
command: [
"bash", "-c", "npm i && npm run start:example:server:groovy"
"bash", "-c", "npm run start:example:server:groovy"
]
ports:
- 30002:30002
Expand Down

0 comments on commit 5a9438b

Please sign in to comment.