You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+110-4Lines changed: 110 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,6 +47,7 @@ This project is used as example in some articles:
47
47
*[Build and Run your Native Image compilation on a Cloud-CI provider like TravisCI](#build-and-run-your-native-image-compilation-on-a-cloud-ci-provider-like-travisci)
48
48
*[Prevent the 'java.lang.UnsatisfiedLinkError: no netty_transport_native_epoll_x86_64 in java.library.path: [/usr/java/packages/lib, /usr/lib64, /lib64, /lib, /usr/lib]' error](#prevent-the-javalangunsatisfiedlinkerror-no-netty_transport_native_epoll_x86_64-in-javalibrarypath-usrjavapackageslib-usrlib64-lib64-lib-usrlib-error)
49
49
*[Tackling the 'There was an error linking the native image /usr/bin/ld: final link failed: Memory exhausted' error](#tackling-the-there-was-an-error-linking-the-native-image-usrbinld-final-link-failed-memory-exhausted-error)
50
+
*[Build and Run your Native Image compilation on GitHub Actions](#build-and-run-your-native-image-compilation-on-github-actions)
50
51
*[Use Docker to compile a Spring Boot App with GraalVM](#use-docker-to-compile-a-spring-boot-app-with-graalvm)
51
52
*[Tackling 'Exception java.lang.OutOfMemoryError in thread "native-image pid watcher"' error](#tackling-exception-javalangoutofmemoryerror-in-thread-native-image-pid-watcher-error)
52
53
*[Run Spring Boot Native Apps in Docker](#run-spring-boot-native-apps-in-docker)
@@ -944,6 +945,61 @@ user 17m46.032s
944
945
sys 0m11.720s
945
946
```
946
947
948
+
# Build and Run your Native Image compilation on GitHub Actions
949
+
950
+
Since Travis laid down their OpenSource support to a massive degree, many maintainers move their repos over to GitHub Actions - see also this post: https://blog.codecentric.de/en/2021/02/github-actions-pipeline/
951
+
952
+
So let's implement a [.github/workflows/native-image-compile.yml](.github/workflows/native-image-compile.yml):
This one does exactly what we did with TravisCI - building the native image using Maven and installing GraalVM beforehand.
1002
+
947
1003
948
1004
# Use Docker to compile a Spring Boot App with GraalVM
949
1005
@@ -1322,6 +1378,20 @@ sys 2m3.179s
1322
1378
The one thing to take into account is that Native Image compilation will be a bit slower now. So if you run on your local machine with lot's of memory, feel free to delete the ` -J-Xmx4G` parameter :)
1323
1379
1324
1380
1381
+
### Work around the Heroku 512MB RAM cap: Building our Dockerimage with GitHub Actions
### Pushing and Releasing our Dockerized Native Spring Boot App on Heroku Container Infrastructure
1326
1396
1327
1397
Now we should be able to finally [push the build Docker image into Heroku's Container Registry](https://devcenter.heroku.com/articles/container-registry-and-runtime#using-a-ci-cd-platform), from where we're able to run our Spring Boot Native app later on.
@@ -1449,9 +1519,45 @@ $ heroku logs -a spring-boot-graal
1449
1519
```
1450
1520
1451
1521
1522
+
### Pushing and Releasing our Dockerized Native Spring Boot App on Heroku Container Infrastructure using GitHub Actions
1523
+
1524
+
We should also use GitHub Actions to [push the build Docker image into Heroku's Container Registry](https://devcenter.heroku.com/articles/container-registry-and-runtime#using-a-ci-cd-platform).
1525
+
1526
+
Therefore we need to configure encrypted variables in our GitHub repository in order to push to Heroku's Container Registry:
1527
+
`DOCKER_USERNAME` and `DOCKER_PASSWORD`. The first is your Heroku eMail, the latter is your Heroku API key. Be sure to prevent displaying the values in the build log:
1528
+
1529
+
With the following configuration inside our [.github/workflows/native-image-compile.yml](.github/workflows/native-image-compile.yml), we should be able to successfully log in to Heroku Container Registry:
1530
+
1531
+
```yaml
1532
+
run: |
1533
+
echo ' Login into Heroku Container Registry first, so that we can push our Image later'
Now after a successful Docker build, that compiles our Spring Boot App into a native executable, we finally need to push the resulting Docker image into Heroku Container Registry.
1538
+
1539
+
Therefore we need to use the correct tag for our Docker image build([see the docs](https://devcenter.heroku.com/articles/container-registry-and-runtime#pushing-an-existing-image):
This means we add the following `docker tag` and `docker push` command into our [.github/workflows/native-image-compile.yml](.github/workflows/native-image-compile.yml):
See the paragraph on how to release to Heroku using Containers at [Pushing and Releasing our Dockerized Native Spring Boot App on Heroku Container Infrastructure](#pushing-and-releasing-our-dockerized-native-spring-boot-app-on-heroku-container-infrastructure).)
1557
+
1452
1558
1453
1559
1454
-
# Autorelease on Docker Hub with TravisCI
1560
+
# Autorelease on Docker Hub with TravisCI & GitHub Actions
1455
1561
1456
1562
We could try to __autorelease to Docker Hub on hub.docker.com:__
1457
1563
@@ -1475,13 +1581,13 @@ __BUT:__ As the automatic builds feature rely on the Docker Hub build infrastruc
1475
1581
[91mError: Image build request failed with exit status 1[0m
1476
1582
```
1477
1583
1478
-
Since our TravisCI build is now enabled to successfully run our GraalVM Native Image compilation in a Docker build, we could live without the automatic builds feature of Docker Hub - and simply push our Travis' build image to Docker Hub also!
1584
+
Since our TravisCI & GitHub Actions builds are now enabled to successfully run our GraalVM Native Image compilation in a Docker build, we could live without the automatic builds feature of Docker Hub - and simply push our build image to Docker Hub also!
1479
1585
1480
1586
Therefore you need to create an Access Token in your Docker Hub account at https://hub.docker.com/settings/security
1481
1587
1482
-
Then head over to your TravisCI project settings and add the environment variables `DOCKER_HUB_TOKEN` and `DOCKER_HUB_USERNAME` as already happended for Heroku Container Registry.
1588
+
Then head over to your TravisCI & GitHub Actions project settings and add the environment variables `DOCKER_HUB_TOKEN` and `DOCKER_HUB_USERNAME` as already happended for Heroku Container Registry.
1483
1589
1484
-
The final step then is to add the correct `docker login` and `docker push` commands to our [.travis.yml](.travis.yml):
1590
+
The final step then is to add the correct `docker login` and `docker push` commands to our [.travis.yml](.travis.yml) and [.github/workflows/native-image-compile.yml](.github/workflows/native-image-compile.yml):
1485
1591
1486
1592
```yaml
1487
1593
# Push to Docker Hub also, since automatic Builds there don't have anough RAM to do a docker build
0 commit comments