Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Add support to publish
Browse files Browse the repository at this point in the history
  • Loading branch information
yamelsenih committed Feb 27, 2023
1 parent c0d0744 commit 69b60bb
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
with:
gradle-version: 8.0.1
arguments: createRelease
env:
GITHUB_DEPLOY_USER: ${{ github.actor }}
GITHUB_DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}

- name: Upload dist app zip artifact
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -207,3 +210,62 @@ jobs:
${{ secrets.DOCKER_REPO_BACKEND }}:${{ github.event.release.tag_name }}
build-args: |
JDK_RELEASE=11-jdk
# Check secrets to push image in docker hub registry
check-do-secrets:
name: Check if digital ocean registry information was set on secrets
needs:
- build-app
runs-on: ubuntu-latest
outputs:
is_have_secrets: ${{ steps.check_secret_job.outputs.is_have_secrets }}
steps:
- id: check_secret_job
run: |
if [[ "${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}" != ""]]; \
then
echo "Secrets to use a container registry are configured in the repo"
echo "is_have_secrets=true" >> $DIGITALOCEAN_ACCESS_TOKEN
else
echo "Secrets to use a container registry were not configured in the repo"
echo "is_have_secrets=false" >> $DIGITALOCEAN_ACCESS_TOKEN
fi
push-imame-do:
name: Push Docker image to Digital Ocean
needs:
- check-do-secrets
# Skip step based on secret
if: needs.check-do-secrets.outputs.is_have_secrets == 'true'
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Download build dist app
uses: actions/download-artifact@v3
with:
name: backend.zip
path: dist

- name: Unzip dist file
run: |
cd dist
unzip -o backend.zip
- uses: actions/checkout@v3
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to DO Container Registry
run: doctl registry login --expiry-seconds 600
- name: Build image
run: docker build -t adempiere-middleware -f docker/Dockerfile .
- name: Tag image
run: docker tag adempiere-middleware registry.digitalocean.com/erpya/adempiere-middleware:${{ github.event.release.tag_name }}
- name: Push image to DO Container Registry
run: docker push registry.digitalocean.com/erpya/adempiere-middleware:${{ github.event.release.tag_name }}

70 changes: 70 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
FROM registry.digitalocean.com/erpya/adempiere-cloud:latest as libs
FROM gradle:7.4.1 as bridge
ARG BUILD_ARTIFACT

COPY --from=libs /opt/Adempiere/jboss/server/adempiere/deploy/adempiere.ear/ /opt/libDeploy/

LABEL maintainer="[email protected]; [email protected]" \
description="ADempiere gRPC All In One Server used as ADempiere backend"

# Init ENV with default values
ENV \
SERVER_PORT="50059" \
SERVICES_ENABLED="access; business; core; dashboarding; dictionary; enrollment; log; ui; workflow; store; pos;" \
SERVER_LOG_LEVEL="WARNING" \
DB_HOST="localhost" \
DB_PORT="5432" \
DB_NAME="adempiere" \
DB_USER="adempiere" \
DB_PASSWORD="adempiere" \
DB_TYPE="PostgreSQL" \
BUILD_ARTIFACT=$BUILD_ARTIFACT



EXPOSE ${SERVER_PORT}

COPY $BUILD_ARTIFACT /opt/Apps/source

RUN cd /opt/libDeploy && \
unzip -o adempiereRoot.war && \
unzip adempiereHome/AdempiereClient.zip && \
mkdir /opt/Apps/source/dependences && \
mv Adempiere/lib/ext/*.jar /opt/Apps/source/dependences/ && \
mv Adempiere.jar /opt/Apps/source/dependences/ && \
mv AdempiereSLib.jar /opt/Apps/source/dependences/ && \
rm /opt/Apps/source/dependences/adempiere-gRPC-Server.jar && \
rm -R /opt/libDeploy && \
cd /opt/Apps/source && \
gradle build && \
unzip -d /opt/Apps /opt/Apps/source/build/distributions/adempiere-customer-backend.zip && \
mv /opt/Apps/adempiere-customer-backend /opt/Apps/ADempiere-gRPC-Server && \
cp /opt/Apps/source/build-docker/all_in_one_connection.yaml /opt/Apps/ADempiere-gRPC-Server/bin/ && \
cp /opt/Apps/source/build-docker/start.sh /opt/Apps/ADempiere-gRPC-Server/bin/ && \
cp /opt/Apps/source/build-docker/all_in_one_connection.yaml /opt/Apps/ADempiere-gRPC-Server/bin/

FROM openjdk:8-jdk-alpine

# timezone
ENV TZ America/Caracas

# Add operative system dependencies
RUN rm -rf /var/cache/apk/* && \
rm -rf /tmp/* && \
apk update && \
apk add --no-cache \
bash \
fontconfig \
ttf-dejavu && \
echo "Set Timezone..." && \
echo $TZ > /etc/timezone && \
apk add --no-cache \
tzdata

COPY --from=bridge /opt/Apps/ADempiere-gRPC-Server /opt/Apps/ADempiere-gRPC-Server

WORKDIR /opt/Apps/ADempiere-gRPC-Server/bin/


# Start app
CMD 'sh' 'start.sh'
12 changes: 12 additions & 0 deletions docker/env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
server:
port: 50059
host: localhost
log_level: WARNING
adempiere_token: adempiere_token_value
database:
host: localhost
port: 5432
name: adempiere_database_value
user: adempiere_user_value
password: adempiere_pass_value
type: PostgreSQL
45 changes: 45 additions & 0 deletions docker/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env sh
# @autor Yamel Senih <[email protected]>

# Set server values
sed -i "s|50059|$SERVER_PORT|g" env.yaml
sed -i "s|WARNING|$SERVER_LOG_LEVEL|g" env.yaml


# create array to iterate
SERVICES_LIST=$(echo $SERVICES_ENABLED | tr "; " "\n")

SERVICES_LIST_TO_SET=""
for SERVICE_ITEM in $SERVICES_LIST
do
# Service to lower case
SERVICE_LOWER_CASE=$(echo $SERVICE_ITEM | tr '[:upper:]' '[:lower:]')

NEW_LINE="\n"
PREFIX=" - "
if [ -z "$SERVICES_LIST_TO_SET" ]
then
NEW_LINE=""
PREFIX="- "
fi

# Add to the list of services
SERVICES_LIST_TO_SET="${SERVICES_LIST_TO_SET}${NEW_LINE}${PREFIX}${SERVICE_LOWER_CASE}"
done

sed -i "s|- services_enabled|$SERVICES_LIST_TO_SET|g" env.yaml

export DEFAULT_JAVA_OPTIONS='"-Xms64M" "-Xmx1512M"'
# Set data base conection values
sed -i "s|localhost|$DB_HOST|g" env.yaml
sed -i "s|5432|$DB_PORT|g" env.yaml
sed -i "s|adempieredb|$DB_NAME|g" env.yaml
sed -i "s|adempiereuser|$DB_USER|g" env.yaml
sed -i "s|adempierepass|$DB_PASSWORD|g" env.yaml
sed -i "s|PostgreSQL|$DB_TYPE|g" env.yaml
sed -i "s|PostgreSQL|$DB_TYPE|g" env.yaml
sed -i "s|$DEFAULT_JAVA_OPTIONS|$GRPC_JAVA_OPTIONS|g" adempiere-middleware-server


# Run app
./adempiere-middleware-server ./env.yaml

0 comments on commit 69b60bb

Please sign in to comment.