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

Commit

Permalink
Feature/#remove docker asset build (#7)
Browse files Browse the repository at this point in the history
* Initial commit for digital ocean publish

* Remove docker build

This pull request remove docker build asset and alow download from
generated asset
  • Loading branch information
yamelsenih authored Apr 6, 2023
1 parent b5034d6 commit 39e4a77
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 117 deletions.
76 changes: 10 additions & 66 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,31 +163,21 @@ jobs:
steps:
- name: Check out the repo
uses: actions/checkout@v3

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

- name: Unzip dist file
- name: Unzip Asset
run: |
cd dist
unzip -o adempiere-middleware.zip
unzip adempiere-middleware.zip -d docker/
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
# CONFIGURE DOCKER SECRETS INTO REPOSITORY
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Push alpine image in Docker Hub
uses: docker/build-push-action@v2
env:
GITHUB_DEPLOY_USER: "${{ github.actor }}"
GITHUB_DEPLOY_TOKEN: "${{ secrets.DEPLOY_TOKEN }}"
GITHUB_DEPLOY_REPOSITORY: ${{ secrets.DEPLOY_REPOSITORY }}
with:
context: .
file: docker/Dockerfile.alpine
Expand All @@ -208,6 +198,13 @@ jobs:
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Download build dist app
uses: actions/download-artifact@v3
with:
name: adempiere-middleware.zip
- name: Unzip Asset
run: |
unzip adempiere-middleware.zip -d docker/
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
Expand All @@ -221,64 +218,11 @@ jobs:

- name: Push alpine image in Docker Hub
uses: docker/build-push-action@v4
env:
GITHUB_DEPLOY_USER: "${{ github.actor }}"
GITHUB_DEPLOY_TOKEN: "${{ secrets.DEPLOY_TOKEN }}"
GITHUB_DEPLOY_REPOSITORY: ${{ secrets.DEPLOY_REPOSITORY }}
with:
context: .
file: docker/Dockerfile
platforms: linux/amd64,linux/amd64/v2,linux/arm64/v8
push: true
tags: |
${{ secrets.DOCKER_REPO_ADEMPIERE_MIDDLEWARE }}:${{ github.event.release.tag_name }}
${{ secrets.DOCKER_REPO_ADEMPIERE_MIDDLEWARE }}:latest
# Check secrets to push image in docker hub registry
check-digital-ocean-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 }}" != "" && \
"${{ secrets.DIGITALOCEAN_ORGANIZATION }}" != "" ]]; \
then
echo "Secrets to use a container registry are configured in the repo"
echo "is_have_secrets=true" >> $GITHUB_OUTPUT
else
echo "Secrets to use a container registry were not configured in the repo"
echo "is_have_secrets=false" >> $GITHUB_OUTPUT
fi
push-imame-do:
name: Push Docker image to Digital Ocean
needs:
- check-digital-ocean-secrets
# Skip step based on secret
if: needs.check-digital-ocean-secrets.outputs.is_have_secrets == 'true'
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- 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 buildx build --platform linux/amd64,linux/amd64/v2,linux/arm64/v8 -t ${{ github.event.repository.name }} --build-arg GITHUB_DEPLOY_USER="${{ github.actor }}" --build-arg GITHUB_DEPLOY_TOKEN="${{ secrets.DEPLOY_TOKEN }}" --build-arg GITHUB_DEPLOY_REPOSITORY="${{ secrets.DEPLOY_REPOSITORY }}" -f docker/Dockerfile .
- name: Tag image
run: docker buildx tag ${{ github.event.repository.name }} registry.digitalocean.com/${{ secrets.DIGITALOCEAN_ORGANIZATION }}/${{ github.event.repository.name }}:${{ github.event.release.tag_name }}
- name: Push image to DO Container Registry
run: docker buildx push registry.digitalocean.com/${{ secrets.DIGITALOCEAN_ORGANIZATION }}/${{ github.event.repository.name }}:${{ github.event.release.tag_name }}

${{ secrets.DOCKER_REPO_ADEMPIERE_MIDDLEWARE }}:latest
29 changes: 5 additions & 24 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
FROM gradle:8.0.2 as builder
ARG BUILD_ARTIFACT \
GITHUB_DEPLOY_USER \
GITHUB_DEPLOY_TOKEN \
GITHUB_DEPLOY_REPOSITORY

LABEL maintainer="[email protected]" \
description="ADempiere gRPC Middleware used as ADempiere backend as little core"

WORKDIR /opt/apps/server

COPY . . /opt/apps/server/

EXPOSE ${SERVER_PORT}

ENV GITHUB_DEPLOY_USER=$GITHUB_DEPLOY_USER \
GITHUB_DEPLOY_TOKEN=$GITHUB_DEPLOY_TOKEN \
GITHUB_DEPLOY_REPOSITORY=$GITHUB_DEPLOY_REPOSITORY

RUN gradle build && \
unzip -d /opt/apps build/distributions/adempiere-middleware.zip && \
mv docker/env.yaml /opt/apps/adempiere-middleware && \
mv docker/start.sh /opt/apps/adempiere-middleware

FROM eclipse-temurin:11-jdk-focal

# Init ENV with default values
Expand All @@ -39,6 +15,11 @@ ENV \

WORKDIR /opt/apps/server

# Copy src files
COPY docker/adempiere-middleware /opt/apps/server
COPY docker/env.yaml /opt/apps/server/env.yaml
COPY docker/start.sh /opt/apps/server/start.sh

# timezone
ENV TZ America/Caracas

Expand Down
32 changes: 5 additions & 27 deletions docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
FROM gradle:8.0.2 as builder
ARG BUILD_ARTIFACT \
GITHUB_DEPLOY_USER \
GITHUB_DEPLOY_TOKEN \
GITHUB_DEPLOY_REPOSITORY

LABEL maintainer="[email protected]" \
description="ADempiere gRPC Middleware used as ADempiere backend as little core"

WORKDIR /opt/apps/server

COPY . . /opt/apps/server/

EXPOSE ${SERVER_PORT}

ENV GITHUB_DEPLOY_USER=$GITHUB_DEPLOY_USER \
GITHUB_DEPLOY_TOKEN=$GITHUB_DEPLOY_TOKEN \
GITHUB_DEPLOY_REPOSITORY=$GITHUB_DEPLOY_REPOSITORY

RUN gradle build && \
unzip -d /opt/apps build/distributions/adempiere-middleware.zip && \
mv docker/env.yaml /opt/apps/adempiere-middleware && \
mv docker/start.sh /opt/apps/adempiere-middleware

FROM eclipse-temurin:11-jdk-alpine

# Init ENV with default values
Expand All @@ -39,6 +15,11 @@ ENV \

WORKDIR /opt/apps/server

# Copy src files
COPY docker/adempiere-middleware /opt/apps/server
COPY docker/env.yaml /opt/apps/server/env.yaml
COPY docker/start.sh /opt/apps/server/start.sh

# timezone
ENV TZ America/Caracas

Expand All @@ -55,9 +36,6 @@ RUN rm -rf /var/cache/apk/* && \
apk add --no-cache \
tzdata


COPY --from=builder /opt/apps/adempiere-middleware/ /opt/apps/server/

RUN addgroup adempiere && \
adduser --disabled-password --gecos "" --ingroup adempiere --no-create-home adempiere && \
chown -R adempiere /opt/apps/server/ && \
Expand Down

0 comments on commit 39e4a77

Please sign in to comment.