Skip to content

Commit

Permalink
feat: add actions
Browse files Browse the repository at this point in the history
  • Loading branch information
wojiushixiaobai committed May 9, 2024
1 parent 3c603ab commit 1e0c5b7
Show file tree
Hide file tree
Showing 8 changed files with 993 additions and 674 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
* text=lf
131 changes: 131 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
on:
push:
branches:
- master
schedule:
- cron: '0 1 * * *'

name: Checkout and Create Release Version

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: check Code
uses: actions/checkout@v4

- name: Check Version
run: |
version=$(curl -s 'https://api.github.com/repos/dataease/dataease/releases/latest' | jq -r ".tag_name")
echo "version=${version}" >> $GITHUB_ENV
- name: Check Release
run: |
if gh release view ${{ env.version }} -R ${{ github.repository }} | grep dataease-${{ env.version }}.tar.gz; then
echo "Release already exists"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Tag
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git tag -a ${{ env.version }} -m "Release ${{ env.version }}"
git push origin ${{ env.version }} || echo "Tag already exists"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
run: |
gh release create ${{ env.version }} -R ${{ github.repository }} --title "Release ${{ env.version }}" --notes "Release ${{ env.version }}" || echo "Release already exists"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build:
needs: check
runs-on: ubuntu-latest
steps:
- name: Check Version
run: |
version=$(curl -s 'https://api.github.com/repos/dataease/dataease/releases/latest' | jq -r ".tag_name")
echo "version=${version}" >> $GITHUB_ENV
- name: Checkout Code
uses: actions/checkout@v3
with:
repository: 'dataease/dataease'
ref: ${{ steps.get-version.outputs.version }}

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '16.15.0'

- name: Build Web
run: |
mvn clean install
cd core && mvn clean package -Pstandalone -U -Dmaven.test.skip=true
- name: Create File
run: |
mkdir -p opt/apps opt/dataease2.0/drivers opt/dataease2.0/cache opt/dataease2.0/data/map opt/dataease2.0/data/static-resource opt/dataease2.0/data/appearance
cp -rf drivers/* opt/dataease2.0/drivers/
cp -rf mapFiles/* opt/dataease2.0/data/map/
cp -rf staticResource/* opt/dataease2.0/data/static-resource/
cp -f core/core-backend/target/CoreApplication.jar opt/apps/app.jar
mv opt dataease-${{ env.version }}
tar -czf dataease-${{ env.version }}.tar.gz dataease-${{ env.version }}
sha256sum dataease-${{ env.version }}.tar.gz > dataease-${{ env.version }}.tar.gz.sha256
- uses: docker/setup-qemu-action@v3

- uses: docker/setup-buildx-action@v3

- name: Get Dockerfile
run: |
wget -O Dockerfile.release https://github.com/wojiushixiaobai/dataease/raw/master/Dockerfile
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Image
uses: docker/build-push-action@v5
with:
context: .
provenance: false
file: Dockerfile.release
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
push: true
tags: |
${{ github.repository_owner }}/dataease:${{ env.version }}
${{ github.repository_owner }}/dataease:latest
ghcr.io/${{ github.repository_owner }}/dataease:${{ env.version }}
ghcr.io/${{ github.repository_owner }}/dataease:latest
outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Upload Release Asset
run: |
gh release upload ${{ env.version }} dataease-${{ env.version }}.tar.gz dataease-${{ env.version }}.tar.gz.sha256 -R ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87 changes: 87 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
FROM debian:bookworm-slim AS builder
ARG TARGETARCH

ARG DEPENDENCIES=" \
ca-certificates \
wget"

RUN set -ex \
&& apt-get update \
&& apt-get -y install --no-install-recommends ${DEPENDENCIES} \
&& echo "no" | dpkg-reconfigure dash \
&& apt-get clean all \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /opt

ARG CHECK_VERSION=v1.0.2
RUN set -e \
&& wget --quiet https://github.com/jumpserver-dev/healthcheck/releases/download/${CHECK_VERSION}/check-${CHECK_VERSION}-linux-${TARGETARCH}.tar.gz \
&& tar -xf check-${CHECK_VERSION}-linux-${TARGETARCH}.tar.gz \
&& mv check /usr/local/bin/ \
&& chown root:root /usr/local/bin/check \
&& chmod 755 /usr/local/bin/check \
&& rm -f check-${CHECK_VERSION}-linux-${TARGETARCH}.tar.gz

RUN mkdir -p /opt/apps/config \
/opt/dataease2.0/drivers \
/opt/dataease2.0/cache \
/opt/dataease2.0/data/map \
/opt/dataease2.0/data/static-resource \
/opt/dataease2.0/data/appearance

RUN set -ex \
&& mkdir -p /deployments \
&& cd /deployments \
&& wget https://github.com/fabric8io-images/run-java-sh/raw/master/fish-pepper/run-java-sh/fp-files/run-java.sh

RUN set -ex \
&& mkdir -p /opt/apps/config \
&& cd /opt/apps/config \
&& wget https://github.com/wojiushixiaobai/dataease/raw/master/config/application.yml

RUN set -ex \
&& wget https://github.com/wojiushixiaobai/dataease/raw/master/docker-entrypoint.sh \
&& chmod +x docker-entrypoint.sh

ADD drivers/* /opt/dataease2.0/drivers/
ADD mapFiles/ /opt/dataease2.0/data/map/
ADD staticResource/ /opt/dataease2.0/data/static-resource/
ADD core/core-backend/target/CoreApplication.jar /opt/apps/app.jar

FROM debian:bookworm-slim
ARG TARGETARCH

ARG DEPENDENCIES=" \
ca-certificates \
openjdk-17-jre-headless"

RUN set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends ${DEPENDENCIES} \
&& echo "no" | dpkg-reconfigure dash \
&& echo "securerandom.source=file:/dev/urandom" >> /etc/java-17-openjdk/security/java.security \
&& sed -i "[email protected]=SSLv3, TLSv1, [email protected]=SSLv3@" /etc/java-17-openjdk/security/java.security \
&& sed -i "s@# export @export @g" ~/.bashrc \
&& sed -i "s@# alias @alias @g" ~/.bashrc \
&& apt-get clean all \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /opt /opt
COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /deployments/run-java.sh /deployments/run-java.sh

WORKDIR /opt/apps

ENV JAVA_APP_DIR=/deployments \
JAVA_MAX_HEAP_RATIO=40 \
JAVA_APP_JAR=/opt/apps/app.jar
ENV JAVA_OPTIONS="-Dfile.encoding=utf-8 -Dloader.path=/opt/apps -Dspring.config.additional-location=/opt/apps/config/"

COPY --from=builder /opt/docker-entrypoint.sh /docker-entrypoint.sh

ENTRYPOINT [ "/docker-entrypoint.sh" ]

EXPOSE 8100

CMD [ "/deployments/run-java.sh" ]
Loading

0 comments on commit 1e0c5b7

Please sign in to comment.