Skip to content

Commit

Permalink
Add support for Shepherd (#6)
Browse files Browse the repository at this point in the history
* vaadin v bump

* pom.xml: remove unused deps

* add vaadin-boot

* Fix vaadin-boot configuration

* Fix maven run configuration

* add github actions

* Maven needs to be run with  -Dvaadin.webpackForFrontendBuild=true

* Add missing validation library

* Mark com.vaadin:vaadin dependency properly as optional

* Initial impl of Dockerfile

* Dockerfile

* Dockerfile: fix missing ARG clause
  • Loading branch information
mvysny committed May 5, 2023
1 parent af28d41 commit 432be6d
Show file tree
Hide file tree
Showing 10 changed files with 391 additions and 256 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Maven

on: [push, pull_request]

jobs:
build:

strategy:
matrix:
os: [ubuntu-latest]
java: [11]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: |
~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', '.mvn/wrapper/maven-wrapper.properties') }}
- name: Build with Maven
run: ./mvnw -C -B -e -V clean package -Dvaadin.webpackForFrontendBuild=true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ drivers/
# Error screenshots generated by TestBench for failed integration tests
error-screenshots/
webpack.generated.js
frontend/generated
package-lock.json
46 changes: 46 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Allows you to run this addon's app easily as a docker container.
# See README.md for more details.
#
# 1. Build the image with: docker build --no-cache -t test/breeze-theme:latest .
# 2. Run the image with: docker run --rm -ti -p8080:8080 test/breeze-theme
#
# Uses Docker Multi-stage builds: https://docs.docker.com/build/building/multi-stage/

# The "Build" stage. Copies the entire project into the container, into the /app/ folder, and builds it.
# The app is actually packaged in src/test/java, so we need to run couple of specialized steps.
FROM eclipse-temurin:17 AS BUILD
COPY . /app/
WORKDIR /app/
# 1. Need to copy all routes to src/main/java otherwise Vaadin plugin won't include JS files into webpack build for all components.
# Workaround for https://github.com/vaadin/flow/issues/14732
RUN cp -r src/test/java/* src/main/java/
# 2. Turn all test dependencies into compile deps, so that test files copied to src/main/java/ are compilable.
RUN sed -i 's_<scope>test</scope>_<!-- -->_g' pom.xml
# 3. Finally, build the app
ARG offlinekey
ENV VAADIN_OFFLINE_KEY=$offlinekey
RUN ./mvnw -C clean package -Pproduction -Dvaadin.webpackForFrontendBuild=true -DskipTests
# Prepare a folder with dependencies
RUN ./mvnw dependency:copy-dependencies -DoutputDirectory=target/deps

# At this point, we have the app as follows:
# 1. All jar deps are at /app/target/deps/*.jar
# 2. We also need to add /app/target/classes/ and /app/target/test-classes/ onto classpath, to include the app itself.


# The "Run" stage. Start with a clean image, and copy over just the app itself, omitting gradle, npm and any intermediate build files.
FROM eclipse-temurin:17
COPY --from=BUILD /app/target/deps /app/
COPY --from=BUILD /app/target/classes /app/classes
COPY --from=BUILD /app/target/test-classes /app/test-classes
WORKDIR /app/
RUN ls -la
SHELL ["/bin/bash", "-c"]
RUN echo $'#!/bin/bash\n\
set -e -o pipefail\n\
CP=`ls *.jar|tr \'\\n\' \':\'`\n\
java -cp "classes:test-classes:$CP" com.example.application.Main' >/app/run
RUN chmod a+x /app/run
EXPOSE 8080
ENTRYPOINT ./run

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ You can still make your own changes on top in the applications theme.

## Running the application

To run the project during development, run `mvn jetty:run`
To run the project during development, run the `Main.java` class from your IDE. Alternatively,
run `mvn exec:java -Dvaadin.webpackForFrontendBuild=true`.

## Cutting releases

Expand Down
23 changes: 23 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<!--
This file is auto-generated by Vaadin.
-->

<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body, #outlet {
height: 100vh;
width: 100%;
margin: 0;
}
</style>
<!-- index.ts is included here automatically (either by the dev server or during the build) -->
</head>
<body>
<!-- This outlet div is where the views are rendered -->
<div id="outlet"></div>
</body>
</html>
Loading

0 comments on commit 432be6d

Please sign in to comment.