From 76dd97b549a06c12aa2273c56044b1cc0f52d01a Mon Sep 17 00:00:00 2001 From: Daniele Viti Date: Sat, 11 Jan 2025 20:49:03 +0100 Subject: [PATCH 01/14] builder --- .github/workflows/build.yaml | 48 ++++++++++++++++++++++++++++++++++++ .project | 11 +++++++++ 2 files changed, 59 insertions(+) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 000000000..108646d5a --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,48 @@ +name: Build CircuitJS1 +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + name: Build the CircuitJS1 application + runs-on: ubuntu-latest + + steps: + # Step 1: Check out the code from the repository + - name: Checkout Code + uses: actions/checkout@v4 + + # Step 2: Set up Java (required for GWT) + - name: Set up Java + uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: "8" + + # Step 3: Install GWT and dependencies + - name: Install GWT + run: | + sudo apt-get update + sudo apt-get install -y unzip + wget http://www.gwtproject.org/compile/download/gwt-2.10.0.zip + unzip gwt-2.10.0.zip -d $HOME + echo "GWT installed." + + # Step 4: Build the CircuitJS1 application + - name: Build using GWT + run: | + export GWT_HOME=$HOME/gwt-2.10.0 + mkdir -p war + java -cp "$GWT_HOME/gwt-dev.jar:$GWT_HOME/gwt-user.jar:." com.google.gwt.dev.Compiler -war war circuitjs1 + + # Step 5: Upload build artifacts + - name: Upload Built Application (WAR Directory) + uses: actions/upload-artifact@v3 + with: + name: circuitjs1-build + path: war diff --git a/.project b/.project index d55af456a..a6924969b 100644 --- a/.project +++ b/.project @@ -42,4 +42,15 @@ org.eclipse.wst.common.project.facet.core.nature com.gwtplugins.gwt.eclipse.core.gwtNature + + + 1736624742049 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + From 2544c92875570fef8217bdf4c6a52386a4175f87 Mon Sep 17 00:00:00 2001 From: Daniele Viti Date: Sat, 11 Jan 2025 20:50:39 +0100 Subject: [PATCH 02/14] changed branch build --- .github/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 108646d5a..4cf3ac8f5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -2,10 +2,10 @@ name: Build CircuitJS1 on: push: branches: - - main + - master pull_request: branches: - - main + - master jobs: build: From 92a4d526935986d5596ad1329210cdc56c0da999 Mon Sep 17 00:00:00 2001 From: Daniele Viti Date: Sat, 11 Jan 2025 20:55:22 +0100 Subject: [PATCH 03/14] fixed gwt link --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4cf3ac8f5..f5e11a61d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -29,7 +29,7 @@ jobs: run: | sudo apt-get update sudo apt-get install -y unzip - wget http://www.gwtproject.org/compile/download/gwt-2.10.0.zip + wget https://github.com/gwtproject/gwt/releases/download/2.10.0/gwt-2.10.0.zip unzip gwt-2.10.0.zip -d $HOME echo "GWT installed." From 03f4970a8d0839039e2e35b1f8774386ed312ec9 Mon Sep 17 00:00:00 2001 From: Daniele Viti Date: Sat, 11 Jan 2025 21:01:26 +0100 Subject: [PATCH 04/14] new pipeline test --- .github/workflows/build.yaml | 50 ++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f5e11a61d..0be403cff 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,23 +1,22 @@ -name: Build CircuitJS1 +name: Build and Deploy CircuitJS1 Docker Image on: push: branches: - - master + - main pull_request: branches: - - master + - main jobs: - build: - name: Build the CircuitJS1 application + build-and-push: runs-on: ubuntu-latest steps: - # Step 1: Check out the code from the repository - - name: Checkout Code + # Step 1: Check out the repository + - name: Check out code uses: actions/checkout@v4 - # Step 2: Set up Java (required for GWT) + # Step 2: Set up Java for GWT build - name: Set up Java uses: actions/setup-java@v3 with: @@ -27,22 +26,39 @@ jobs: # Step 3: Install GWT and dependencies - name: Install GWT run: | - sudo apt-get update - sudo apt-get install -y unzip + sudo apt-get update && sudo apt-get install -y unzip wget https://github.com/gwtproject/gwt/releases/download/2.10.0/gwt-2.10.0.zip unzip gwt-2.10.0.zip -d $HOME echo "GWT installed." - # Step 4: Build the CircuitJS1 application - - name: Build using GWT + # Step 4: Build the CircuitJS1 application using GWT + - name: Compile with GWT run: | export GWT_HOME=$HOME/gwt-2.10.0 - mkdir -p war - java -cp "$GWT_HOME/gwt-dev.jar:$GWT_HOME/gwt-user.jar:." com.google.gwt.dev.Compiler -war war circuitjs1 + cd src + # Compile the module using its fully qualified name + java -cp "$GWT_HOME/gwt-dev.jar:$GWT_HOME/gwt-user.jar:." com.google.gwt.dev.Compiler -war ../war com.lushprojects.circuitjs1 - # Step 5: Upload build artifacts - - name: Upload Built Application (WAR Directory) + # Step 5: Package the GWT build artifacts (optional for debugging) + - name: Upload Build Artifacts uses: actions/upload-artifact@v3 with: - name: circuitjs1-build + name: circuitjs1-war path: war + + # Step 6: Log in to GitHub Container Registry (GHCR) + - name: Log in to GHCR + uses: docker/login-action@v2 + with: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Step 7: Build the Docker image + - name: Build Docker image + run: | + docker build -t ghcr.io/${{ github.repository_owner }}/circuitjs1:latest -f ./Dockerfile . + + # Step 8: Push the Docker image to GHCR + - name: Push Docker image + run: | + docker push ghcr.io/${{ github.repository_owner }}/circuitjs1:latest From 39446c4e167f2eeba8aae818acffb13b3332b76c Mon Sep 17 00:00:00 2001 From: Daniele Viti Date: Sat, 11 Jan 2025 21:01:46 +0100 Subject: [PATCH 05/14] - --- .github/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0be403cff..cd21a92cd 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -2,10 +2,10 @@ name: Build and Deploy CircuitJS1 Docker Image on: push: branches: - - main + - master pull_request: branches: - - main + - master jobs: build-and-push: From 0886870622fd8777fc75b3b8fe9de7e61521eb7f Mon Sep 17 00:00:00 2001 From: Daniele Viti Date: Sat, 11 Jan 2025 21:06:05 +0100 Subject: [PATCH 06/14] Update build.yaml --- .github/workflows/build.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index cd21a92cd..505923077 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -20,8 +20,8 @@ jobs: - name: Set up Java uses: actions/setup-java@v3 with: - distribution: "temurin" - java-version: "8" + distribution: 'temurin' + java-version: '8' # Step 3: Install GWT and dependencies - name: Install GWT @@ -35,9 +35,8 @@ jobs: - name: Compile with GWT run: | export GWT_HOME=$HOME/gwt-2.10.0 - cd src - # Compile the module using its fully qualified name - java -cp "$GWT_HOME/gwt-dev.jar:$GWT_HOME/gwt-user.jar:." com.google.gwt.dev.Compiler -war ../war com.lushprojects.circuitjs1 + # Ensure the src/ directory is included in the classpath + java -cp "$GWT_HOME/gwt-dev.jar:$GWT_HOME/gwt-user.jar:./src" com.google.gwt.dev.Compiler -war war com.lushprojects.circuitjs1 # Step 5: Package the GWT build artifacts (optional for debugging) - name: Upload Build Artifacts From 12ad62d090cc3c8bbd096b893ed2aa9faa423542 Mon Sep 17 00:00:00 2001 From: Daniele Viti Date: Sat, 11 Jan 2025 21:08:55 +0100 Subject: [PATCH 07/14] Update build.yaml --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 505923077..48f65a885 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -36,7 +36,7 @@ jobs: run: | export GWT_HOME=$HOME/gwt-2.10.0 # Ensure the src/ directory is included in the classpath - java -cp "$GWT_HOME/gwt-dev.jar:$GWT_HOME/gwt-user.jar:./src" com.google.gwt.dev.Compiler -war war com.lushprojects.circuitjs1 + java -cp "$GWT_HOME/gwt-dev.jar:$GWT_HOME/gwt-user.jar:./src" com.google.gwt.dev.Compiler -war war com.lushprojects.circuitjs1.circuitjs1 # Step 5: Package the GWT build artifacts (optional for debugging) - name: Upload Build Artifacts From 86bd120e1dd73ce962bab6ec567112c3e377c86b Mon Sep 17 00:00:00 2001 From: Daniele Viti Date: Sat, 11 Jan 2025 21:16:49 +0100 Subject: [PATCH 08/14] changed registry login --- .github/workflows/build.yaml | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 48f65a885..e62ddcdfc 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -20,8 +20,8 @@ jobs: - name: Set up Java uses: actions/setup-java@v3 with: - distribution: 'temurin' - java-version: '8' + distribution: "temurin" + java-version: "8" # Step 3: Install GWT and dependencies - name: Install GWT @@ -46,18 +46,23 @@ jobs: path: war # Step 6: Log in to GitHub Container Registry (GHCR) - - name: Log in to GHCR + - name: Log in to the Container registry uses: docker/login-action@v2 with: + registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - # Step 7: Build the Docker image - - name: Build Docker image - run: | - docker build -t ghcr.io/${{ github.repository_owner }}/circuitjs1:latest -f ./Dockerfile . + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - # Step 8: Push the Docker image to GHCR - - name: Push Docker image - run: | - docker push ghcr.io/${{ github.repository_owner }}/circuitjs1:latest + # Step 7: Build and Push the Docker image + - name: Build and push Backend Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: Dockerfile + push: true + tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/circuitjs1:${{ github.ref_name }} + env: + ADC_VERSION: ${{ github.ref_name }} From ee649106ef2cf17571984e152170f78d658fd9e3 Mon Sep 17 00:00:00 2001 From: Daniele Viti Date: Sat, 11 Jan 2025 21:19:53 +0100 Subject: [PATCH 09/14] set registry --- .github/workflows/build.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e62ddcdfc..9e1d799b5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -6,6 +6,8 @@ on: pull_request: branches: - master +env: + REGISTRY: ghcr.io jobs: build-and-push: From 6eb8a740c0140701877b2646ad72a66d08c61bb0 Mon Sep 17 00:00:00 2001 From: Daniele Viti Date: Sat, 11 Jan 2025 21:25:27 +0100 Subject: [PATCH 10/14] added dockerfile --- Dockerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..bdcd7acf2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# Base Nginx image +FROM nginx:stable-alpine + +# Set a directory in the container for static files +WORKDIR /usr/share/nginx/html + +# Copy the pre-compiled WAR artifacts (static files) into the container +COPY war/ . + +# Expose port 80 for incoming HTTP traffic +EXPOSE 80 + +# Start the Nginx server in the foreground +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file From 7aa37dcd902b6fbb4779b229e2eaa0721392baa4 Mon Sep 17 00:00:00 2001 From: Daniele Viti Date: Sat, 11 Jan 2025 21:44:07 +0100 Subject: [PATCH 11/14] changed dockerfile with tomcat --- Dockerfile | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index bdcd7acf2..f6b1c3df6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,18 @@ -# Base Nginx image -FROM nginx:stable-alpine +# Use the official Tomcat base image. Replace "9.0" with the Tomcat version you require. +FROM tomcat:9.0 -# Set a directory in the container for static files -WORKDIR /usr/share/nginx/html +# Set an environment variable for the version of the application +ENV WAR_FILE_NAME circuitjs1-war.war -# Copy the pre-compiled WAR artifacts (static files) into the container -COPY war/ . +# Optional: Set the timezone (if required) +# ENV TZ=UTC -# Expose port 80 for incoming HTTP traffic -EXPOSE 80 +# Copy the WAR file to Tomcat's webapps directory +# Assuming the WAR file is in the same directory as the Dockerfile during build +COPY $WAR_FILE_NAME /usr/local/tomcat/webapps/ -# Start the Nginx server in the foreground -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +# Expose the default Tomcat port +EXPOSE 8080 + +# Command to start Tomcat (inherited from the base image) +CMD ["catalina.sh", "run"] \ No newline at end of file From 058617a3717b3c1596bbd343ff73e3373282d560 Mon Sep 17 00:00:00 2001 From: Daniele Viti Date: Sat, 11 Jan 2025 22:18:44 +0100 Subject: [PATCH 12/14] working dockerfile --- .dockerignore | 1 + Dockerfile | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 14 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..7ce98a21e --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +WEB-INF/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index f6b1c3df6..bdcd7acf2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,14 @@ -# Use the official Tomcat base image. Replace "9.0" with the Tomcat version you require. -FROM tomcat:9.0 +# Base Nginx image +FROM nginx:stable-alpine -# Set an environment variable for the version of the application -ENV WAR_FILE_NAME circuitjs1-war.war +# Set a directory in the container for static files +WORKDIR /usr/share/nginx/html -# Optional: Set the timezone (if required) -# ENV TZ=UTC +# Copy the pre-compiled WAR artifacts (static files) into the container +COPY war/ . -# Copy the WAR file to Tomcat's webapps directory -# Assuming the WAR file is in the same directory as the Dockerfile during build -COPY $WAR_FILE_NAME /usr/local/tomcat/webapps/ +# Expose port 80 for incoming HTTP traffic +EXPOSE 80 -# Expose the default Tomcat port -EXPOSE 8080 - -# Command to start Tomcat (inherited from the base image) -CMD ["catalina.sh", "run"] \ No newline at end of file +# Start the Nginx server in the foreground +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file From dbfb986122ba0b95478f2268688f9a2a1684db51 Mon Sep 17 00:00:00 2001 From: Daniele Viti Date: Sat, 11 Jan 2025 22:28:06 +0100 Subject: [PATCH 13/14] httpd for directory listing --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bdcd7acf2..459b52c8a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Base Nginx image -FROM nginx:stable-alpine +FROM httpd:alpine # Set a directory in the container for static files WORKDIR /usr/share/nginx/html From 42da47699a9ba18befffe5f0384ee93b3631dd20 Mon Sep 17 00:00:00 2001 From: Daniele Viti Date: Sat, 11 Jan 2025 22:30:13 +0100 Subject: [PATCH 14/14] added tools listing --- Dockerfile | 2 +- war/index.html | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 war/index.html diff --git a/Dockerfile b/Dockerfile index 459b52c8a..bdcd7acf2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Base Nginx image -FROM httpd:alpine +FROM nginx:stable-alpine # Set a directory in the container for static files WORKDIR /usr/share/nginx/html diff --git a/war/index.html b/war/index.html new file mode 100644 index 000000000..d3c7bf7ae --- /dev/null +++ b/war/index.html @@ -0,0 +1,82 @@ + + + + + + Electronics Tools + + + +
+

Electronics Tools

+

Your one-stop destination for electronics calculations and simulators.

+
+ + + \ No newline at end of file