Skip to content

Commit

Permalink
Merge pull request #17 from CourseOrchestra/docker
Browse files Browse the repository at this point in the history
Docker
  • Loading branch information
cursBoris authored Nov 22, 2024
2 parents db2d05a + f2eeb20 commit 6a37b5a
Show file tree
Hide file tree
Showing 13 changed files with 210 additions and 35 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/_discussions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

All workflows that will be called before pr should be called from ci-pr.yml.
All workflows that will be called after pushing to main should be called from ci-push.yml.

Tests, linters and other quality assurance for module should run inside of workflow named "quality-assurance.yml".
Building and deploying artifact logic for module should run inside of workflow named "deploy.yml".

For version validation you should specify version obtaining logic in .vuh file.
18 changes: 18 additions & 0 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: ci

on:
pull_request:
branches: [ main ]

jobs:

validate-version:
name: Validate version
uses: ./.github/workflows/validate-current-version.yml
with:
VUH_VERSION: 'v2.9.2'

quality-assurance-api:
name: Quality assurance
uses: ./.github/workflows/quality-assurance.yml
needs: validate-version
24 changes: 24 additions & 0 deletions .github/workflows/ci-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: ci

on:
push:
branches: [ main ]

jobs:

deploy:
name: Deploy mellophone2
uses: ./.github/workflows/deploy.yml
with:
VUH_VERSION: 'v2.9.2'
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

release-notes-generation:
name: Release generation
uses: ./.github/workflows/release-notes-generation.yml
with:
VUH_VERSION: 'v2.9.2'
CHANGELOG_GENERATOR_VERSION: 'v1.0.2'
needs: [deploy]
Original file line number Diff line number Diff line change
@@ -1,46 +1,58 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: ci-mellophone2-prod
name: Deploy mellophone2

# Triggers the workflow on push or pull request events but only for the master branch
on:
push:
branches: [ main ]
workflow_call:
inputs:
VUH_VERSION: { required: true, type: string }
secrets:
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:

name: Deploy mellophone2
runs-on: ubuntu-latest

environment: deployenv
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Download vuh
run: |
curl https://raw.githubusercontent.com/Greewil/version-update-helper/${{ inputs.VUH_VERSION }}/vuh.sh -O -J -L
chmod +x vuh.sh
- name: Get release version
id: artifact_version
run: |
cur_version=$(./vuh.sh lv -q)
echo "release version: $cur_version"
echo "VERSION=$cur_version" >> "$GITHUB_OUTPUT"
- name: Set up JDK 17 enviroment on ubuntu-latest...
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Build mellophone2 with maven
run: mvn clean package
- name: Extract pom project version
run: echo ::set-output name=version::$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
id: projectversiongroup
- uses: papeloto/action-zip@v1
with:
files:
target/mellophone2-${{ steps.projectversiongroup.outputs.version }}.jar
target/mellophone2-${{ steps.artifact_version.outputs.VERSION }}.jar
target/classes/application.yml
target/classes/config/config.xml
dest: ./artifact_for_ftp/mellophone2-${{ steps.projectversiongroup.outputs.version }}.zip
dest: ./artifact_for_ftp/mellophone2-${{ steps.artifact_version.outputs.VERSION }}.zip
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: mellophone2-${{ steps.projectversiongroup.outputs.version }}
path: ./artifact_for_ftp/mellophone2-${{ steps.projectversiongroup.outputs.version }}.zip
name: mellophone2-${{ steps.artifact_version.outputs.VERSION }}
path: ./artifact_for_ftp/mellophone2-${{ steps.artifact_version.outputs.VERSION }}.zip

- name: 📂 Upload artifact to ftp
uses: SamKirkland/[email protected]
with:
Expand All @@ -49,19 +61,21 @@ jobs:
password: ${{ secrets.FTP_CURS_PWD }}
server-dir: development/curs-mellophone2/
local-dir: ./artifact_for_ftp/
- name: Build docker image
run: |
docker build -t curs/mellophone2 .
- name: Log in to Docker Hub

- name: Login to container registry (to Docker Hub)
if: success() && github.ref == 'refs/heads/main'
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push
- name: Build and push
if: success() && github.ref == 'refs/heads/main'
run: |
docker push curs/mellophone2:latest
uses: docker/build-push-action@v6
with:
push: true
tags: curs/mellophone2:latest , curs/mellophone2:${{ steps.artifact_version.outputs.VERSION }}
context: .

- name: Build documentation
run: |
./_builddoc.sh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: ci-mellophone2-pr
name: Quality Assurance API

on:
pull_request:
branches: [ main ]
workflow_call:

jobs:
build:

name: Quality Assurance API
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up JDK 17 enviroment on ubuntu-latest...
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build mellophone2 with maven

- name: Build mellophone2 with maven and run tests
run: mvn clean test

- name: Build documentation
run: |
./_builddoc.sh
59 changes: 59 additions & 0 deletions .github/workflows/release-notes-generation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Release generation

on:
workflow_call:
inputs:
VUH_VERSION: { required: true, type: string }
CHANGELOG_GENERATOR_VERSION: { required: true, type: string }

jobs:

generate_release_from_new_commits:
runs-on: ubuntu-latest
steps:

- name: Git clone this repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: download vuh
run: |
curl https://raw.githubusercontent.com/Greewil/version-update-helper/${{ inputs.VUH_VERSION }}/vuh.sh -O -J -L
chmod +x vuh.sh
- name: download release notes generator
run: |
curl https://raw.githubusercontent.com/Greewil/release-notes-generator/${{ inputs.CHANGELOG_GENERATOR_VERSION }}/gen_release_notes.sh -O -J -L
chmod +x gen_release_notes.sh
- name: get release tag_name
id: release_tag
run: |
cur_version=$(./vuh.sh lv -q)
[ "$cur_version" != '' ] || exit 1
echo "release version: $cur_version"
echo "RELEASE_TAG=$cur_version" >> "$GITHUB_OUTPUT"
- name: generate release notes
id: changelog
run: |
./gen_release_notes.sh -i .. -lt -f changelog.md
[ -f "changelog.md" ] && CHANGELOG=$(cat changelog.md) || CHANGELOG=''
echo "$CHANGELOG"
echo 'FINAL_CHANGELOG<<EOF' >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
[ -f 'changelog.md' ] && echo "IS_EMPTY=false" >> "$GITHUB_OUTPUT"
[ -f 'changelog.md' ] || echo "IS_EMPTY=true" >> "$GITHUB_OUTPUT"
- name: Create Release
uses: actions/create-release@v1
if: ${{ steps.changelog.outputs.IS_EMPTY == 'false' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "${{ steps.release_tag.outputs.RELEASE_TAG }}"
release_name: "${{ steps.release_tag.outputs.RELEASE_TAG }}"
body: ${{ steps.changelog.outputs.FINAL_CHANGELOG }}
26 changes: 26 additions & 0 deletions .github/workflows/validate-current-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Check new version is greater than main version

on:
workflow_call:
inputs:
VUH_VERSION: { required: true, type: string }

jobs:

validate-version:
name: Check new version is greater than main version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download vuh
run: |
curl https://raw.githubusercontent.com/Greewil/version-update-helper/${{ inputs.VUH_VERSION }}/vuh.sh -O -J -L
chmod +x vuh.sh
- name: Compare versions
run: |
./vuh.sh sv -q && [ "$(./vuh.sh lv -q)" = "$(./vuh.sh sv -q)" ] || exit 1
16 changes: 16 additions & 0 deletions .vuh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This is version update helper config.
# It contains specific to current project variables. With use of this file vuh understands how to extract project's
# version and where project's version variable is located. Vuh can't work with any project without this file!
# If .vuh file located in comparing branch is different from local .vuh file vuh will by default take
# configuration files from handling branches (f.e. local .vuh to work with local version and origin/main:.vuh
# to work with origin/main's version). If your project dont have .vuh file in project's root folder vuh will advice
# you to configure that project.
#
# (Version update helper's page: https://github.com/Greewil/version-update-helper)

# This configuration file is based on project-config-templates/xml-versions-template.

MAIN_BRANCH_NAME='main'
VERSION_FILE='pom.xml'
TEXT_BEFORE_VERSION_CODE='<version>'
TEXT_AFTER_VERSION_CODE='<\/version>'
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You may check mellophone is running by issuing the following http request:

[source]
----
http://localhost:8082/mellophone/login?sesid=123&login=login&pwd=pwd
http://localhost:8082/mellophone/login?sesid=123&login=user222&pwd=pwd222
----

If credentials are correct you will get 200 response, otherwise you will get 403 error.
5 changes: 4 additions & 1 deletion doc/pages/general.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@
** сервлеты, обслуживающие прямые запросы с серверов веб-приложений;
** один сервлет, обслуживающий запросы от клиентских браузеров, поступающих в виде запросов на отображение фрейма или картинки на странице веб-приложения.
* Протокол, по которому любое веб-приложение может взаимодействовать с сервером аутентификации для обеспечения общей аутентификации.
##
##

Для использования метода /authentication.gif mellophone потребует наличия ssl сертификата для https соединнеия.
Для этого можно будет либо настроить соединение на внешнем веб сервере (через который запросы проходят на mellophone), либо настроить сам mellophone (настройки tomcat для spring boot в application.yml), чтобы он использовал серитификат.
2 changes: 2 additions & 0 deletions docker-example-config/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
server:
port: 8082
ssl:
enabled: false


mellophone:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ru.curs</groupId>
<artifactId>mellophone2</artifactId>
<version>1.5.0</version>
<version>1.6.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
7 changes: 5 additions & 2 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
# port: 8082

server:
port: 443
# port: 443
port: 8082
ssl:
enabled: false
key-store: keystore.p12
key-store-password: sdgdhfjhjghjghjghjgh
keyStoreType: PKCS12
Expand All @@ -13,7 +15,8 @@ server:


mellophone:
configFile: D:/IdeaProjects/mellophone2/src/main/resources/config/config.xml
configFile: src/main/resources/config/config.xml
# configFile: D:/IdeaProjects/mellophone2/src/main/resources/config/config.xml



Expand Down

0 comments on commit 6a37b5a

Please sign in to comment.