Skip to content

Commit

Permalink
Merge pull request #1 from evgri243/evgri243/add-docker-container
Browse files Browse the repository at this point in the history
* Added Dockerfile to create a containerized environment with pre-installed dependencies for running the plugin.
* Updated runPluginStarter.sh to add default values and better error handling for arguments.
* Updated GitHub Actions workflow (build.yml) to include building and pushing of Docker images to the GitHub Container Registry.
* Moved .github folder to the repository root to make it visible to GitHub Actions.
  • Loading branch information
evgri243 authored Nov 3, 2023
2 parents b3816ef + f1fdb52 commit 9f8a3fa
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 21 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build & Push

on:
push:
branches:
- main
pull_request:
branches:
- main

# cancel workflow if there is already one running
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true


jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/[email protected]
with:
java-version: 17
distribution: liberica
- name: Build plugin
run: ./gradlew buildPlugin
working-directory: ide-former-plugin

# build docker container
docker:
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
platforms: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
tags: ghcr.io/${{ github.repository }}/runner:latest,ghcr.io/${{ github.repository }}/runner:${{ github.sha }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/runner:latest




32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM ubuntu:20.04

# Install Java
RUN apt-get update && apt-get install -y \
openjdk-17-jdk \
&& java -version

# Install Git
RUN apt-get install -y \
git \
&& git --version

# Install Python3 and pip3
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
python3-setuptools \
python3-wheel \
&& python3 --version

# Disable gradle daemon
ENV GRADLE_OPTS "-Dorg.gradle.daemon=false"

# Copy the plugin
COPY ide-former-plugin /ide-former-plugin

# prebuild the plugin with gradle
RUN cd /ide-former-plugin && ./gradlew buildPlugin

ENTRYPOINT ["bash", "/ide-former-plugin/runPluginStarter.sh"]

CMD []
20 changes: 0 additions & 20 deletions ide-former-plugin/.github/workflows/build.yml

This file was deleted.

38 changes: 37 additions & 1 deletion ide-former-plugin/runPluginStarter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,40 @@ if uname -s | grep -iq cygwin ; then
PWD=$(cygpath -w "$PWD")
fi

"$DIR/gradlew" -p "$DIR" runIdeAssistantPlugin -Prunner=ide-server -PpathToProject="$1" -PserverHost="$2" -PserverPort="$3"
# check number of arguments
if [ $# -gt 3 ]; then
echo "Illegal number of parameters"
echo "Usage: runPluginStarter.sh <pathToProject> <serverHost> <serverPort>"
echo "\t<pathToProject> - path to the project to be opened in IDE, default is the plugin itself"
echo "\t<serverHost> - host of the server to connect to, default is localhost"
echo "\t<serverPort> - port of the server to connect to, default is 8080"
echo ""
echo "Examples:"
echo "\t./runPluginStarter.sh /project"
echo "\t./runPluginStarter.sh /project localhost 9080"
exit 1
fi

# set default values
if [ -z "$1" ]; then
echo "No path to project specified. Using the plugin itself at $DIR"
PATH_TO_PROJECT="$DIR"
else
PATH_TO_PROJECT=$1
fi

if [ -z "$2" ]; then
echo "No server host specified. Using 127.0.0.1"
SERVER_HOST="127.0.0.1"
else
SERVER_HOST=$2
fi

if [ -z "$3" ]; then
echo "No server port specified. Using 8080"
SERVER_PORT="8080"
else
SERVER_PORT=$3
fi

"$DIR/gradlew" -p "$DIR" runIdeAssistantPlugin -Prunner=ide-server -PpathToProject="$PATH_TO_PROJECT" -PserverHost="$SERVER_HOST" -PserverPort="$SERVER_PORT"

0 comments on commit 9f8a3fa

Please sign in to comment.