Skip to content

Commit

Permalink
Automatically create Beacon Network Docker image on "vX.X.X" tags
Browse files Browse the repository at this point in the history
  • Loading branch information
redmitry committed Nov 10, 2023
1 parent be7b4ff commit 6d726d2
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 35 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Beacon Network Deploy

on:
push:
branches:
- master
tags:
- 'v*.*.*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: gitlab-bsc-maven # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Deploy to BSC GitLab Maven Repository
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
MAVEN_USERNAME: gitlab-bsc-maven
MAVEN_PASSWORD: ${{ secrets.BSC_GITLAB_MAVEN_REPO }}

- name: Log into the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
if: github.ref_type == 'tag'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for the Docker image
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
if: github.ref_type == 'tag'
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push the Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
if: github.ref_type == 'tag'
with:
context: .
file: ./docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
35 changes: 0 additions & 35 deletions .github/workflows/maven-publish.yml

This file was deleted.

23 changes: 23 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Beacon Network 2.0 image
FROM quay.io/wildfly/wildfly:30.0.0.Final-jdk17

# patch WildFly with latest yasson library
COPY ./docker/yasson $JBOSS_HOME/modules/system/layers/base/org/eclipse/yasson/

# add PostgreSQL java driver and latest Yasson snapshot
COPY ./docker/postgresql $JBOSS_HOME/modules/system/layers/base/org/postgresql/

# configure Beacon Network datasource
RUN /bin/sh -c 'echo -e "embed-server --std-out=echo\n \
/subsystem=undertow/server=default-server/ajp-listener=ajp:add(socket-binding=ajp, scheme=https, redirect-socket=https, enabled=true)\n \
/subsystem=datasources/jdbc-driver=postgresql:add(driver-name=postgresql,driver-module-name=org.postgresql,driver-xa-datasource-class-name=org.postgresql.xa.PGXADataSource)\n \
/subsystem=datasources/data-source=BeaconNetwork:add(driver-name=postgresql,jndi-name=java:jboss/datasources/BeaconNetwork,connection-url=\${env.BEACON_NETWORK_DB_CONNECTION_URL},user-name=\${env.BEACON_NETWORK_DB_USERNAME},password=\${env.BEACON_NETWORK_DB_PASSWORD})\n \
stop-embedded-server" > $JBOSS_HOME/bin/wildfly-config.cli'

RUN $JBOSS_HOME/bin/jboss-cli.sh --file="$JBOSS_HOME/bin/wildfly-config.cli"
RUN rm -rf $JBOSS_HOME/standalone/configuration/standalone_xml_history/current/*

ADD ./target/beacon-network-v2-*.war $JBOSS_HOME/standalone/deployments/beacon-network-v2.war

# Expose AJP port
EXPOSE 8009
14 changes: 14 additions & 0 deletions docker/postgresql/main/module.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version='1.0' encoding='UTF-8'?>

<module xmlns="urn:jboss:module:1.9" name="org.postgresql">

<resources>
<!--the name of your driver -->
<resource-root path="postgresql-42.6.0.jar"/>
</resources>

<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Binary file added docker/postgresql/main/postgresql-42.6.0.jar
Binary file not shown.
31 changes: 31 additions & 0 deletions docker/yasson/main/module.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2018 Red Hat, Inc.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<module name="org.eclipse.yasson" xmlns="urn:jboss:module:1.7">

<properties>
<property name="jboss.api" value="private"/>
</properties>

<dependencies>
<module name="javax.enterprise.api"/>
<module name="javax.json.api"/>
<module name="javax.json.bind.api"/>
</dependencies>
<resources>
<resource-root path="yasson-3.0.4-SNAPSHOT.jar"/>
</resources>
</module>
Binary file added docker/yasson/main/yasson-3.0.4-SNAPSHOT.jar
Binary file not shown.

0 comments on commit 6d726d2

Please sign in to comment.