Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 添加构建镜像与release的action #7

Merged
merged 25 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Configuration for Release Drafter: https://github.com/toolmantim/release-drafter
name-template: 'v$NEXT_PATCH_VERSION 🌈'
tag-template: 'v$NEXT_PATCH_VERSION'
version-template: $MAJOR.$MINOR.$PATCH
# Emoji reference: https://gitmoji.carloscuesta.me/
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- 'kind/feature'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- 'regression'
- 'kind/bug'
- title: 📝 Documentation updates
labels:
- 'doc'
- 'documentation'
- 'kind/doc'
- title: 👻 Maintenance
labels:
- chore
- dependencies
- 'kind/chore'
- 'kind/dep'
- title: 🚦 Tests
labels:
- test
- tests
exclude-labels:
- reverted
- no-changelog
- skip-changelog
- invalid
change-template: '* $TITLE (#$NUMBER) @$AUTHOR'
template: |
## What’s Changed
$CHANGES
62 changes: 62 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# This is a basic workflow to help you get started with Actions

name: build docker image

# Controls when the action will run.
on:
push:
branches:
- main
release:
types: [created,published] # 表示在创建新的 Release 时触发

# Allows you to run this workflow manually from the Actions tab
# 可以手动触发
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
tags:
description: 'Test scenario tags'

jobs:
buildx:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
# 所需要的体系结构,可以在 Available platforms 步骤中获取所有的可用架构
platforms: linux/arm64,linux/amd64
# 镜像推送时间
push: ${{ github.event_name != 'pull_request' }}
# 给清单打上多个标签
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.GITHUB_REPOSITORY_NAME_PART }}:latest
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.GITHUB_REPOSITORY_NAME_PART }}:${{ env.GITHUB_REF_NAME }}
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release Drafter

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- main
# pull_request event is required only for autolabeler
pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [opened, reopened, synchronize]
# pull_request_target event is required for autolabeler to support PRs from forks
# pull_request_target:
# types: [opened, reopened, synchronize]

permissions:
contents: read

jobs:
update_release_draft:
permissions:
contents: write # for release-drafter/release-drafter to create a github release
pull-requests: write # for release-drafter/release-drafter to add label to PR
runs-on: ubuntu-latest
steps:
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV

# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
# with:
# config-name: my-config.yml
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 changes: 16 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
FROM maven:3.8.6-openjdk-11 AS builder

WORKDIR /app
ENV JAR_FILE="/app/server/huntly-server/target/huntly-server-*.jar"

COPY app .

RUN cd server \
&& mvn dependency:go-offline -B \
&& mvn clean package -DignoreSnapshots=true -Dhttps.protocols=TLSv1.2 -U \
&& mv ${JAR_FILE} /app/server.jar

FROM openjdk:11

LABEL maintainer="lcomplete"
LABEL version = "0.1.0"

WORKDIR /app

VOLUME /data

RUN mkdir -p /data /data/lucene

ARG JAR_FILE=./app/server/huntly-server/target/huntly-server-*.jar
ARG JAR_PATH=/app/server.jar

COPY ${JAR_FILE} ${JAR_PATH}
RUN mkdir -p /data/lucene

ENV JAR_PATH="/app/server.jar"
ENV JAVA_ARGS="-Xms128m -Xmx1024m"
ENV VM_ARGS="-Duser.timezone=GMT+08"
ENV APP_ARGS=""
ENV PROFILE="default"
ENV PORT=80
ENV JAR_PATH=${JAR_PATH}

EXPOSE ${PORT}
EXPOSE 443

COPY --from=builder ${JAR_PATH} ${JAR_PATH}

ENTRYPOINT ["sh", "-c", "java $JAVA_ARGS $VM_ARGS -jar $JAR_PATH --spring.profiles.active=$PROFILE --server.port=$PORT --huntly.dataDir=/data/ --huntly.luceneDir=/data/lucene $APP_ARGS" ]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ You can use docker or java to run the server.
### Run with docker

```sh
docker run -d --name huntly -p <host port>:80 -v <host directory>:/data lcomplete/huntly:<tag>
mkdir huntly && cd huntly
docker run -itd --name huntly --restart=always -p <host port>:80 -v `pwd`/data:/data lcomplete/huntly
```

\<host port\> and \<host directory\> Replace with the ones you want to use.
always pull the latest image. if you need to upgrade, you can delete the local latest image and run the startup command again.

\<tag\> Replace with the version number, which is currently `0.1.0`.

### Run with the Java command

Expand Down
7 changes: 3 additions & 4 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ Password: huntlydemo
### 使用 docker 运行

```sh
docker run -d --name huntly -p <host port>:80 -v <host directory>:/data lcomplete/huntly:<tag>
mkdir huntly && cd huntly
docker run -itd --name huntly --restart=always -p <host port>:80 -v `pwd`/data:/data lcomplete/huntly
```

\<host port\> 和 \<host directory\> 替换为自己想使用的。

\<tag\> 替换为版本号,目前版本为 `0.1.0` 。
总是拉取latest的镜像,如需要升级,可删除本地的latest,然后再次运行启动命令即可。

### 使用 Java 命令运行

Expand Down
13 changes: 7 additions & 6 deletions app/server/huntly-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.huntly</groupId>
<artifactId>integrated</artifactId>
<version>${revision}</version>
</parent>

<artifactId>huntly-server</artifactId>

<name>huntly-server</name>
<description>huntly api server</description>

Expand All @@ -25,7 +25,7 @@
<yarn.version>v1.22.19</yarn.version>
<frontend-maven-plugin.version>1.12.1</frontend-maven-plugin.version>
</properties>

<dependencies>
<dependency>
<groupId>com.huntly</groupId>
Expand Down Expand Up @@ -159,7 +159,7 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -218,7 +218,8 @@
<goal>yarn</goal>
</goals>
<configuration>
<arguments>install</arguments>
<arguments>install --strict-ssl=false</arguments>
<!-- <npmRegistryURL>https://registry.npmmirror.com/</npmRegistryURL> -->
</configuration>
</execution>

Expand Down