Skip to content

Commit

Permalink
build: 使用github action 制作镜像
Browse files Browse the repository at this point in the history
  • Loading branch information
liuruibin committed Nov 2, 2023
1 parent 626d320 commit 49d14b1
Show file tree
Hide file tree
Showing 13 changed files with 181 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build-and-push-to-dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: build-and-push-to-dockerhub

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Prepare
id: prepare
run: |
DOCKER_IMAGE=metersphere/standalone
DOCKER_PLATFORMS=linux/amd64,linux/arm64
TAG_NAME=v3.x
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME}"
echo ::set-output name=docker_image::${DOCKER_IMAGE}
echo ::set-output name=version::${TAG_NAME}
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
--build-arg VERSION=${TAG_NAME} \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg --no-cache \
--build-arg VCS_REF=${GITHUB_SHA::8} \
${DOCKER_IMAGE_TAGS} .
- name: Set up Docker Buildx
uses: crazy-max/ghaction-docker-buildx@v3
- name: Docker Buildx (build)
run: |
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
- name: Login to Registry
uses: docker/login-action@v1
with:
username: metersphere
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Docker Buildx (push)
run: |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
.DS_Store
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM registry.cn-qingdao.aliyuncs.com/metersphere/metersphere:v3.x as metersphere
FROM registry.cn-qingdao.aliyuncs.com/metersphere/task-runner:v3.x as task-runner
FROM registry.cn-qingdao.aliyuncs.com/metersphere/result-hub:v3.x as result-hub

FROM registry.cn-qingdao.aliyuncs.com/metersphere/alpine-openjdk21-jre

COPY --from=metersphere /app /metersphere
COPY --from=task-runner /app /task-runner
COPY --from=result-hub /app /result-hub

COPY --from=task-runner /opt/jmeter /opt/jmeter

ENV AB_OFF=true
ENV MS_VERSION=${MS_VERSION}

ADD start.sh /start.sh
ADD metersphere.sh /metersphere.sh
ADD task-runner.sh /task-runner.sh
ADD result-hub.sh /result-hub.sh

RUN chmod +x /start.sh
ENTRYPOINT ["sh", "/start.sh"]

3 changes: 3 additions & 0 deletions conf/metersphere.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
logger.sql.level=info
management.endpoints.enabled-by-default=true
springdoc.api-docs.groups.enabled=true
6 changes: 6 additions & 0 deletions conf/redisson.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
singleServerConfig:
password: ${REDIS_PASSWORD}
address: "redis://${REDIS_HOST}:${REDIS_PORT}"
database: 0
threads: 8
nettyThreads: 32
1 change: 1 addition & 0 deletions conf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
13_20180929_184557
42 changes: 42 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: "3"
services:
metersphere:
image: metersphere/standalone:v3.x
container_name: allinone
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://${MS_MYSQL_HOST}:${MS_MYSQL_PORT}/${MS_MYSQL_DB}?autoReconnect=false&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&useSSL=false&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27
SPRING_DATASOURCE_USERNAME: ${MS_MYSQL_USER}
SPRING_DATASOURCE_PASSWORD: ${MS_MYSQL_PASSWORD}
KAFKA_PARTITIONS: 4
KAFKA_REPLICAS: 1
KAFKA_TOPIC: ${MS_KAFKA_TOPIC}
KAFKA_LOG_TOPIC: ${MS_KAFKA_LOG_TOPIC}
KAFKA_TEST_TOPIC: ${MS_KAFKA_TEST_TOPIC}
KAFKA_REPORT_TOPIC: ${MS_KAFKA_REPORT_TOPIC}
KAFKA_BOOTSTRAP-SERVERS: ${MS_KAFKA_HOST}:${MS_KAFKA_PORT}
JMETER_IMAGE: ${MS_JMETER_IMAGE}
K8S_NODE-CONTROLLER-IMAGE: ${MS_IMAGE_PREFIX}/node-controller:${MS_IMAGE_TAG}
TCP_MOCK_PORT: ${MS_TCP_MOCK_PORT}
SPRING_SESSION_TIMEOUT: '30d'
FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS: 'true'
REDIS_HOST: ${MS_REDIS_HOST}
REDIS_PORT: ${MS_REDIS_PORT}
REDIS_PASSWORD: ${MS_REDIS_PASSWORD}
MINIO_ENDPOINT: ${MS_MINIO_ENDPOINT}
MINIO_ACCESS-KEY: ${MS_MINIO_ACCESS_KEY}
MINIO_SECRET-KEY: ${MS_MINIO_SECRET_KEY}
extra_hosts:
- "task-runner:127.0.0.1"
ports:
- ${MS_SERVER_PORT}:8081
- ${MS_TASK_RUNNER_PORT}:6000
healthcheck:
test: [ "CMD", "nc", "-zv", "localhost", "8081" ]
interval: 6s
timeout: 10s
retries: 50
restart: always
volumes:
- ./conf:/opt/metersphere/conf
- ./logs:/opt/metersphere/logs

28 changes: 28 additions & 0 deletions install.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
MS_IMAGE_PREFIX=registry.cn-qingdao.aliyuncs.com/metersphere
MS_JMETER_IMAGE=registry.cn-qingdao.aliyuncs.com/metersphere/jmeter:5.6.2-release1
MS_BASE=/opt
MS_REDIS_PORT=6379
MS_TCP_MOCK_PORT=10000-10010
MS_SERVER_PORT=8081
MS_REDIS_HOST=172.16.200.18
MS_TASK_RUNNER_PORT=6000
MS_NODE_EXPORTER_PORT=9100
MS_MYSQL_HOST=172.16.200.18
MS_MYSQL_PASSWORD=Password123@mysql
MS_KAFKA_HOST=172.16.200.18
MS_KAFKA_LOG_TOPIC=JMETER_LOGS
MS_KAFKA_TOPIC=JMETER_METRICS
MS_KAFKA_PORT=9092
MS_MYSQL_PORT=3306
MS_MINIO_ENDPOINT=http://172.16.200.18:9000
MS_DOCKER_SUBNET=172.30.10.0/24
MS_MYSQL_USER=root
MS_KAFKA_REPORT_TOPIC=JMETER_REPORTS
MS_MINIO_ACCESS_KEY=admin
MS_REDIS_PASSWORD=Password123@redis
MS_IMAGE_TAG=v3.x
MS_ENTERPRISE_ENABLE=false
MS_MINIO_SECRET_KEY=Password123@minio
MS_PROMETHEUS_PORT=9090
MS_KAFKA_TEST_TOPIC=LOAD_TESTS
MS_MYSQL_DB=metersphere
Empty file added logs/.gitkeep
Empty file.
8 changes: 8 additions & 0 deletions metersphere.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

export JAVA_CLASSPATH=/metersphere:/opt/jmeter/lib/ext/*:/metersphere/lib/*
export JAVA_MAIN_CLASS=io.metersphere.Application
export JAVA_OPTIONS="-Dfile.encoding=utf-8 -Djava.awt.headless=true --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED"
sh /deployments/run-java.sh


8 changes: 8 additions & 0 deletions result-hub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

export JAVA_CLASSPATH=/result-hub:/opt/jmeter/lib/ext/*:/result-hub/lib/*
export JAVA_MAIN_CLASS=io.metersphere.result.Application
export JAVA_OPTIONS="-Dfile.encoding=utf-8 -Djava.awt.headless=true --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED"
sh /deployments/run-java.sh


7 changes: 7 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

sh /metersphere.sh & sh task-runner.sh & sh result-hub.sh




8 changes: 8 additions & 0 deletions task-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

export JAVA_CLASSPATH=/task-runner:/task-runner/lib/*
export JAVA_MAIN_CLASS=io.metersphere.Application
export JAVA_OPTIONS="-Dfile.encoding=utf-8 -Djava.awt.headless=true --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED"

sh /deployments/run-java.sh

0 comments on commit 49d14b1

Please sign in to comment.