From 0967c8d72c2b373baf3600930c48eb020699f7e2 Mon Sep 17 00:00:00 2001 From: joffrey-bion Date: Sat, 12 Dec 2020 21:30:29 +0100 Subject: Push Docker image to Heroku, remove Travis CI --- .github/workflows/ci.yml | 76 ++++++++++++++++++++---------------------------- .travis.yml | 21 ------------- sw-server/Dockerfile | 6 +++- 3 files changed, 37 insertions(+), 66 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf36ba72..909ab1aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Set up JDK 13 uses: actions/setup-java@v1.4.3 with: @@ -32,54 +33,41 @@ jobs: - name: Build with Gradle run: ./gradlew build - - name: Docker push to GitHub Container Registry - uses: docker/build-push-action@v1 - with: - path: ./sw-server - username: ${{ github.actor }} - password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }} - registry: ghcr.io - repository: joffrey-bion/seven-wonders-server - tag_with_ref: true - tag_with_sha: true + # technically optional, brings support for more platform to Docker Buildx + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + # required for Docker build/push + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 - - name: Docker push to DockerHub - uses: docker/build-push-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 with: - path: ./sw-server username: hildan password: ${{ secrets.DOCKERHUB_TOKEN }} - repository: hildan/seven-wonders-server - tag_with_ref: true - tag_with_sha: true -# - name: Docker push to GitHub Packages -# uses: docker/build-push-action@v1 -# with: -# path: ./sw-server -# username: ${{ github.actor }} -# password: ${{ github.token }} -# registry: docker.pkg.github.com -# repository: joffrey-bion/seven-wonders/sw-server -# tag_with_ref: true -# tag_with_sha: true + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }} -# - name: Docker push to Heroku -# uses: docker/build-push-action@v1 -# with: -# path: ./sw-server -# username: _ -# password: ${{ secrets.HEROKU_API_KEY }} -# registry: registry.heroku.com -# repository: seven-wonders-online/web -# tag_with_ref: true -# tag_with_sha: true + - name: Login to Heroku Container Registry + uses: docker/login-action@v1 + with: + registry: registry.heroku.com + username: ${{ secrets.HEROKU_EMAIL }} + password: ${{ secrets.HEROKU_API_KEY }} -# - name: Docker push to Heroku -# uses: akhileshns/heroku-deploy@v3.0.4 -# with: -# heroku_api_key: ${{secrets.HEROKU_API_KEY}} -# heroku_app_name: "seven-wonders-online" -# heroku_email: ${{secrets.HEROKU_EMAIL}} -# usedocker: true -# appdir: "./sw-server" + - name: Build and push to DockerHub and GitHub Container Registry + uses: docker/build-push-action@v2 + with: + context: ./sw-server + file: ./sw-server/Dockerfile + push: true + tags: | + hildan/seven-wonders-server:latest + ghcr.io/joffrey-bion/seven-wonders-server:latest + registry.heroku.com/seven-wonders-online/web diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4954cb26..00000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: java - -# These files change at every build, and should not be cached -# https://docs.travis-ci.com/user/languages/java/#Caching -before_cache: - - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ - -# Cache Gradle's dependencies and wrapper download -cache: - directories: - - $HOME/.gradle/caches/ - - $HOME/.gradle/wrapper/ - - frontend/node_modules/ - -deploy: - provider: heroku - api_key: - secure: "B9fxlvYGhUHXMRRYAfPH+sUKW3f8tKZ6d8b6nWTzsZMF2SyGTSW9QQC24W4wfpzjSLRZe1cwy8H/iXBGuL6+x4DKYq9j7kiLIq4sDsy5FYXU5goTnUIX8hrbKaWExDn/8TA2bxKQRtv21AhGJwOpVW3a3hNpYtA55gm8b4mLp4cGh7ofiO7JbrEHDRkZuYUyIf5a0G79QS9U9KHpeygRkjvmcUJ9nSDjyIBWFq8+hnN62hJlK+cFns+Vljv1R2kmNIVu++2T27mCOAGyLnWMhlj6bbCQu+ZYngZ/kCDcpmr/YzTBGeZgNwcV37BydpddsEjKgYDGlkyjjEbAC13xzDHLGT/NkgdQtd2vAPvvOEbJF/qKIDD/IHu/YZ2s09Ougf/Qe9LrbKUbTzllbKQqVfB8LNUiZnE6+iqgPHojgn8iY4QOSMLqd3WnQpfGC4CWLKfe2Uuy3MLHG3z3ELXYeAmDPDoO0027S7AobMWtvvfF2FijE1+G7WHAul2654h8MH06muCrJufp/5YUPt4DLbEpwEfo2LD/qbTJ95vc5dGNGNMsE2dUQEPXQsvPPI4Cp7xJK1Md1mxR1MoNTZ9fFzZkSYSvD3/TNA0W3jGV0hHtM9FRd+tDK5WHe0+RmZcQs4NBRnFGF4KJ3u8ev16BpU/DR27b7H6d5nxXkXbHAm0=" - app: - master: seven-wonders-online diff --git a/sw-server/Dockerfile b/sw-server/Dockerfile index 7c372052..740c2514 100644 --- a/sw-server/Dockerfile +++ b/sw-server/Dockerfile @@ -2,7 +2,11 @@ FROM openjdk:11-jre EXPOSE 80 +# Heroku uses the PORT environment variable, it ignores EXPOSE. +# This also allows to specify a custom port when running the container even outside of Heroku. +ENV PORT 80 + ARG JAR_FILE=build/libs/sw-server.jar COPY ${JAR_FILE} app.jar -ENTRYPOINT ["java", "-Dserver.port=80", "-jar", "/app.jar"] +ENTRYPOINT ["java", "-Dserver.port=$PORT", "-jar", "/app.jar"] -- cgit