-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from CMIPT/develop
V0.1.0
- Loading branch information
Showing
98 changed files
with
6,991 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# WARN: | ||
# For production, you must update those | ||
GIT_USER_PASSWORD=git | ||
SPRING_DRUID_PASSWORD=druid | ||
GIT_SERVER_DOMAIN=localhost | ||
SPRING_MAIL_HOST= | ||
SPRING_MAIL_PORT= | ||
SPRING_MAIL_USERNAME= | ||
SPRING_MAIL_PASSWORD= | ||
SPRING_MAIL_PROTOCOL= | ||
MD5_SALT="Is that the best you can do?" | ||
GCS_SSH_MAPPING_PORT=10623 | ||
FRONT_END_REVERSE_PROXY_PORT=80 | ||
|
||
|
||
# NOTE: | ||
# This is for development, you could update them | ||
GCS_SPRING_MAPPING_PORT=8080 | ||
|
||
# NOTE: | ||
# Make sure GCS_SSH_MAPPING_PORT and GCS_SPRING_MAPPING_PORT could be | ||
# accessed by others | ||
POSTGRES_MAPPING_PATH=/var/gcs/postgres | ||
TARGET_JAR_PATH=./target/gcs-0.1.0-SNAPSHOT.jar | ||
|
||
# NOTE: | ||
# In most situations, you do not need to update those | ||
GIT_USER_NAME=git | ||
GIT_USER_MAIN_GROUP=git | ||
GIT_USER_HOME=/home/git | ||
GITOLITE_REPOSITORY=${GIT_USER_HOME}/gitolite | ||
GITOLITE_INSTALLATION_DIR=${GIT_USER_HOME}/bin | ||
GITOLITE_ADMIN_REPOSITORY=/root/gitolite-admin | ||
GITOLITE_ADMIN_REPOSITORY_USER_NAME=root | ||
GITOLITE_ADMIN_REPOSITORY_USER_EMAIL=root@localhost | ||
POSTGRES_USER=postgres | ||
POSTGRES_PASSWORD=postgres | ||
POSTGRES_DB=postgres | ||
JAVA_WORKING_DIRECTORY=/gcs | ||
|
||
SPRING_PROFILES_ACTIVE=prod | ||
SPRING_DATASOURCE_URL=jdbc:postgresql://gcs-postgres:5432/${POSTGRES_DB} | ||
SPRING_DATASOURCE_USERNAME=${POSTGRES_USER} | ||
SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD} | ||
SPRING_DRUID_USERNAME=druid | ||
SPRING_REDIS_HOST=gcs-redis | ||
SPRING_REDIS_PORT=6379 | ||
SPRING_MAIL_DEFAULT_ENCODING=UTF-8 | ||
GIT_SERVER_PORT=${GCS_SSH_MAPPING_PORT} | ||
GIT_SERVER_USERNAME=${GIT_USER_NAME} | ||
GIT_SERVER_HOME=${GIT_USER_HOME} | ||
GIT_SERVER_ADMIN_REPOSITORY=${GITOLITE_ADMIN_REPOSITORY} | ||
FRONT_END_URL= | ||
|
||
GCS_LOGGING_DIRECTORY=/var/gcs/logs | ||
# every log file's max size is 10MB | ||
GCS_LOGGING_FILE_MAX_SIZE=10MB | ||
# keep 30 days logs | ||
GCS_LOGGING_MAX_HISTORY=30 | ||
# total size of logs is 1GB | ||
GCS_LOGGING_TOTAL_SIZE_CAP=1GB | ||
|
||
# NOTE: | ||
# Those below are to avoid hard-code, | ||
# You need not modify them | ||
GITOLITE_USER_REPOSITORIES=${GIT_USER_HOME}/repositories | ||
DATABASE_INIT_SCRIPT_PATH=./database/init | ||
GITOLITE_PATH=./3rdparty/gitolite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Google Java Style Format | ||
|
||
on: | ||
pull_request: | ||
branches: [ master, develop ] | ||
|
||
jobs: | ||
java-formatting: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.PAT }} | ||
|
||
- name: Check for Java files | ||
id: check_java_files | ||
run: | | ||
if [ -n "$(find . -name '*.java' -print -quit)" ]; then | ||
echo "java_files_exist=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "java_files_exist=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Set up openjdk-17 | ||
uses: actions/setup-java@v4 | ||
if: steps.check_java_files.outputs.java_files_exist == 'true' | ||
with: | ||
distribution: 'zulu' | ||
java-version: '17' | ||
|
||
- name: Google Java Style Format | ||
if: steps.check_java_files.outputs.java_files_exist == 'true' | ||
uses: axel-op/googlejavaformat-action@v3 | ||
with: | ||
# --aosp: 4-space indentation | ||
args: "--replace --aosp" | ||
# Can not auto commit, we'll commit manually | ||
skip-commit: true | ||
|
||
- name: Commit Changes | ||
if: steps.check_java_files.outputs.java_files_exist == 'true' | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: "Apply Google Java Style Format" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "3rdparty/gitolite"] | ||
path = 3rdparty/gitolite | ||
url = https://github.com/sitaramc/gitolite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
FROM ubuntu:24.04 | ||
|
||
RUN apt-get update && apt-get install -y sudo openssh-server git openjdk-17-jre-headless nodejs | ||
|
||
ARG GIT_USER_NAME=git | ||
ARG GIT_USER_MAIN_GROUP="$GIT_USER_NAME" | ||
ARG GIT_USER_PASSWORD="$GIT_USER_NAME" | ||
ARG GIT_USER_HOME="/home/$GIT_USER_NAME" | ||
ARG GITOLITE_REPOSITORY="$GIT_USER_HOME/gitolite" | ||
ARG GITOLITE_INSTALLATION_DIR="$GIT_USER_HOME/bin" | ||
ARG GITOLITE_ADMIN_REPOSITORY=/root/gitolite-admin | ||
ARG GITOLITE_ADMIN_REPOSITORY_USER_NAME=root | ||
ARG GITOLITE_ADMIN_REPOSITORY_USER_EMAIL=root@localhost | ||
ARG GITOLITE_PATH=./3rdparty/gitolite | ||
ARG JAVA_WORKING_DIRECTORY=/gcs | ||
ARG TARGET_JAR_PATH=./target/gcs.jar | ||
|
||
RUN useradd -m "$GIT_USER_NAME" && echo "$GIT_USER_NAME:$GIT_USER_PASSWORD" | chpasswd | ||
|
||
COPY "$GITOLITE_PATH" "$GITOLITE_REPOSITORY" | ||
|
||
RUN chown -R "$GIT_USER_NAME:$GIT_USER_MAIN_GROUP" "$GITOLITE_REPOSITORY" && \ | ||
sudo -u "$GIT_USER_NAME" mkdir -p "$GITOLITE_INSTALLATION_DIR" && \ | ||
sudo -u "$GIT_USER_NAME" "$GITOLITE_REPOSITORY/install" -to "$GITOLITE_INSTALLATION_DIR" && \ | ||
ssh-keygen -t rsa -b 4096 -f /root/.ssh/id_rsa -N "" && \ | ||
cp /root/.ssh/id_rsa.pub "$GIT_USER_HOME/root.pub" && \ | ||
chown "$GIT_USER_NAME:$GIT_USER_MAIN_GROUP" "$GIT_USER_HOME/root.pub" && \ | ||
sudo -u "$GIT_USER_NAME" "$GITOLITE_INSTALLATION_DIR/gitolite" setup -pk "$GIT_USER_HOME/root.pub" | ||
|
||
RUN service ssh restart && \ | ||
ssh-keyscan -p 22 localhost >> /root/.ssh/known_hosts && \ | ||
git clone "$GIT_USER_NAME@localhost:gitolite-admin" "$GITOLITE_ADMIN_REPOSITORY" && \ | ||
mkdir -p "$GITOLITE_ADMIN_REPOSITORY/conf/gitolite.d/user" && \ | ||
mkdir -p "$GITOLITE_ADMIN_REPOSITORY/conf/gitolite.d/repository" && \ | ||
echo "\ | ||
@admin = root\n\ | ||
repo gitolite-admin\n\ | ||
RW+ = @admin\n\ | ||
repo testing\n\ | ||
RW+ = @admin\n\ | ||
include \"gitolite.d/user/*.conf\"\n\ | ||
include \"gitolite.d/repository/*.conf\"\n\ | ||
@all_public_repo = testing\n\ | ||
repo @all_public_repo\n\ | ||
R = @all" > "$GITOLITE_ADMIN_REPOSITORY/conf/gitolite.conf" && \ | ||
git -C "$GITOLITE_ADMIN_REPOSITORY" config user.name "$GITOLITE_ADMIN_REPOSITORY_USER_NAME" && \ | ||
git -C "$GITOLITE_ADMIN_REPOSITORY" config user.email "$GITOLITE_ADMIN_REPOSITORY_USER_EMAIL" && \ | ||
git -C "$GITOLITE_ADMIN_REPOSITORY" commit -am "Init the gitolite-admin" && \ | ||
git -C "$GITOLITE_ADMIN_REPOSITORY" push | ||
|
||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime | ||
|
||
EXPOSE 22 8080 | ||
|
||
WORKDIR "$JAVA_WORKING_DIRECTORY" | ||
|
||
COPY "$TARGET_JAR_PATH" "gcs.jar" | ||
|
||
RUN echo "\ | ||
service ssh restart && \ | ||
git -C $GITOLITE_ADMIN_REPOSITORY fetch && \ | ||
git -C $GITOLITE_ADMIN_REPOSITORY reset --hard origin/master && \ | ||
cp ~/.ssh/id_rsa.pub $GITOLITE_ADMIN_REPOSITORY/keydir/root.pub && \ | ||
(git -C $GITOLITE_ADMIN_REPOSITORY commit -am 'Update root.pub' && git push -f || true) && \ | ||
java -jar gcs.jar" \ | ||
> \ | ||
"start.sh" | ||
|
||
ENTRYPOINT ["bash", "start.sh"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# gcs-back-end | ||
|
||
`git` 中央仓库服务的后端实现。 | ||
|
||
# 部署介绍 | ||
|
||
## 使用 `docker-compose` 进行部署 | ||
|
||
现在提供了 `docker-compose` 部署方式。 | ||
|
||
第一步,使用以下命令获取仓库: | ||
|
||
```bash | ||
git clone --recursive https://github.com/CMIPT/gcs-back-end.git | ||
``` | ||
|
||
或者: | ||
|
||
```bash | ||
git clone https://github.com/CMIPT/gcs-back-end.git | ||
git submodule init | ||
git submodule update | ||
``` | ||
|
||
确保安装 `mvn` 和 `jdk17`,使用 `mvn` 打包: | ||
|
||
```bash | ||
mvn package | ||
``` | ||
|
||
配置 `.env` 中的环境变量,对于生产环境,你需要配置: | ||
|
||
```bash | ||
GIT_USER_PASSWORD= | ||
POSTGRES_PASSWORD= | ||
SPRING_DRUID_PASSWORD= | ||
GIT_SERVER_DOMAIN= | ||
SPRING_MAIL_HOST= | ||
SPRING_MAIL_PORT= | ||
SPRING_MAIL_USERNAME= | ||
SPRING_MAIL_PASSWORD= | ||
SPRING_MAIL_PROTOCOL= | ||
MD5_SALT= | ||
GCS_SSH_MAPPING_PORT= | ||
GCS_SPRING_MAPPING_PORT= | ||
TARGET_JAR_PATH= | ||
``` | ||
|
||
对于开发环境,你只需要配置: | ||
|
||
```bash | ||
SPRING_MAIL_HOST= | ||
SPRING_MAIL_PORT= | ||
SPRING_MAIL_USERNAME= | ||
SPRING_MAIL_PASSWORD= | ||
SPRING_MAIL_PROTOCOL= | ||
TARGET_JAR_PATH= | ||
``` | ||
|
||
配置完成后,使用 `docker-compose build` 构建镜像,使用 `docker-compose up -d` 启动服务。 | ||
|
||
在开发过程中,可以通过以下命令对包进行替换: | ||
|
||
```bash | ||
mvn package && \ | ||
docker cp <jar_path> <container_id>:/gcs/gcs.jar && \ | ||
docker restart <container_id> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# gcs-back-end | ||
|
||
The back-end for git center server. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
# USAGE: bash clean_ubuntu.sh [config_file] | ||
|
||
config_file=${1:-"config.json"} | ||
|
||
# TODO: reuse the log_error and log_info functions from deploy_ubuntu.sh | ||
log_error () { | ||
echo -e "\e[31m[ERROR]: $1\e[0m" | ||
exit 1 | ||
} | ||
|
||
log_info () { | ||
echo "[INFO]: $1" | ||
} | ||
|
||
log_info "Cleaning up..." | ||
python script/deploy_helper.py \ | ||
--config-path "$config_file" \ | ||
--clean \ | ||
--distro ubuntu \ | ||
--default-config-path ./config_default.json || \ | ||
log_error "Failed to run deploy_helper.py for cleaning up the environment" |
Oops, something went wrong.