forked from mosip/admin-ui
-
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 mosip#213 from syedsalman3753/MOSIP-28148
[MOSIP-28148] added admintest docker files
- Loading branch information
Showing
3 changed files
with
178 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ on: | |
- 1.0.* | ||
- develop | ||
- 1.1.* | ||
- MOSIP-11719 | ||
- MOSIP* | ||
- 1.2.* | ||
|
||
jobs: | ||
|
@@ -124,3 +124,136 @@ jobs: | |
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
|
||
maven-build-admintest: | ||
runs-on: ubuntu-latest | ||
env: | ||
SERVICE_NAME: admintest | ||
SERVICE_LOCATION: ./admintest | ||
CONFIG_LOCATION: ./src/main/resources/ | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
ref: ${{ github.ref }} | ||
java-version: 11 | ||
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml | ||
settings-path: ${{ github.workspace }} # location for the settings.xml file | ||
|
||
- name: Setup branch and env | ||
run: | | ||
# Strip git ref prefix from version | ||
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV | ||
echo "GPG_TTY=$(tty)" >> $GITHUB_ENV | ||
- uses: actions/cache@v1 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven-${{ env.BRANCH_NAME }} | ||
- name: Install xmllint | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install libxml2-utils | ||
- name: Setup the settings file for ossrh server | ||
run: echo "<settings> <servers> <server> <id>ossrh</id> </server> </servers> <profiles> <profile> <id>ossrh</id> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <profile> <id>allow-snapshots</id> <activation><activeByDefault>true</activeByDefault></activation> <repositories> <repository> <id>snapshots-repo</id> <url>https://oss.sonatype.org/content/repositories/snapshots</url> <releases><enabled>false</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> <repository> <id>releases-repo</id> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url> <releases><enabled>false</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> </repositories> </profile> </profiles> </settings> " > $GITHUB_WORKSPACE/settings.xml | ||
|
||
|
||
- name: Build admintest with Maven | ||
run: | | ||
cd ./${{env.SERVICE_LOCATION}} | ||
mvn clean install -s $GITHUB_WORKSPACE/settings.xml | ||
- name: Ready the springboot artifacts | ||
run: | | ||
cd ${{env.SERVICE_LOCATION}} | ||
mkdir -p ./build_files/ | ||
cp $( find -name 'adminui-*.jar' -type f ) ./build_files | ||
cp -r ${{env.CONFIG_LOCATION}} ./build_files | ||
zip -r ${{env.SERVICE_NAME}}.zip ./build_files | ||
- name: Upload the springboot jars | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: ${{env.SERVICE_NAME}} | ||
path: ${{env.SERVICE_LOCATION}}/${{env.SERVICE_NAME}}.zip | ||
|
||
- uses: 8398a7/action-slack@v3 | ||
with: | ||
status: ${{ job.status }} | ||
fields: repo,message,commit,workflow,job # selectable (default: repo,message) | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} # required | ||
if: failure() # Pick up events even if the job fails or is canceled. | ||
|
||
docker-build-admintest: | ||
needs: maven-build-admintest | ||
runs-on: ubuntu-latest | ||
env: | ||
NAMESPACE: ${{ secrets.dev_namespace_docker_hub }} | ||
SERVICE_NAME: admintest | ||
SERVICE_LOCATION: ./admintest | ||
DOCKER_BUILDKIT: 1 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/download-artifact@v1 | ||
with: | ||
name: ${{env.SERVICE_NAME}} | ||
path: ./${{env.SERVICE_LOCATION}} | ||
|
||
- name: Setup branch name | ||
run: | | ||
# Strip git ref prefix from version | ||
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV | ||
echo ${{ env.BRANCH_NAME }} | ||
- name: Get version info from pom | ||
id: getPomVersion | ||
uses: mavrosxristoforos/[email protected] | ||
with: | ||
xml-file: ./${{ env.SERVICE_LOCATION }}/pom.xml | ||
xpath: /*[local-name()="project"]/*[local-name()="version"] | ||
|
||
- name: Extract the admintest jar and its dependency configs | ||
run: | | ||
cd ./${{env.SERVICE_LOCATION}} | ||
unzip "${{env.SERVICE_NAME}}.zip" | ||
- name: Get current date | ||
id: date | ||
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" | ||
|
||
- name: Build image | ||
run: | | ||
cd ./${{env.SERVICE_LOCATION}} | ||
mkdir docker-image-build | ||
cp -r ./build_files ./docker-image-build/build_files | ||
cp -r ./entrypoint.sh ./docker-image-build/entrypoint.sh | ||
cp ./Dockerfile ./docker-image-build/Dockerfile | ||
cd docker-image-build | ||
docker build . --file Dockerfile --build-arg SOURCE=mosip --build-arg COMMIT_HASH=$(git rev-parse HEAD) --build-arg COMMIT_ID=$(git rev-parse --short HEAD) --build-arg BUILD_TIME=${{steps.date.outputs.date}} --tag ${{ env.SERVICE_NAME }} | ||
- name: Log into registry | ||
run: echo "${{ secrets.release_docker_hub }}" | docker login -u ${{ secrets.actor_docker_hub }} --password-stdin | ||
|
||
- name: Push image | ||
run: | | ||
IMAGE_ID=$NAMESPACE/$SERVICE_NAME | ||
# Change all uppercase to lowercase | ||
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | ||
echo "push version ${{steps.getPomVersion.outputs.info}}" | ||
if [[ $BRANCH_NAME == master ]]; then | ||
VERSION=latest | ||
else | ||
VERSION=$BRANCH_NAME | ||
fi | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker tag $SERVICE_NAME $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:$VERSION | ||
- uses: 8398a7/action-slack@v3 | ||
with: | ||
status: ${{ job.status }} | ||
fields: repo,message,commit,workflow,job # selectable (default: repo,message) | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEVOPS_WEBHOOK }} # required | ||
if: failure() # Pick up events even if the job fails or is canceled. |
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,40 @@ | ||
FROM openjdk:11-jre | ||
|
||
ARG SOURCE | ||
ARG COMMIT_HASH | ||
ARG COMMIT_ID | ||
ARG BUILD_TIME | ||
LABEL source=${SOURCE} | ||
LABEL commit_hash=${COMMIT_HASH} | ||
LABEL commit_id=${COMMIT_ID} | ||
LABEL build_time=${BUILD_TIME} | ||
|
||
# can be passed during Docker build as build time environment for github branch to pickup configuration from. | ||
ARG container_user=mosip | ||
|
||
# can be passed during Docker build as build time environment for github branch to pickup configuration from. | ||
ARG container_user_group=mosip | ||
|
||
# can be passed during Docker build as build time environment for github branch to pickup configuration from. | ||
ARG container_user_uid=1001 | ||
|
||
# can be passed during Docker build as build time environment for github branch to pickup configuration from. | ||
ARG container_user_gid=1001 | ||
|
||
# set working directory for the user | ||
ENV work_dir=/home/${container_user}/ | ||
|
||
# install packages and create user | ||
RUN groupadd -g ${container_user_gid} ${container_user_group} \ | ||
&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/bash -m ${container_user} -d ${work_dir} | ||
|
||
# select container user for all tasks | ||
USER ${container_user_uid}:${container_user_gid} | ||
|
||
COPY --chown=${container_user_uid}:${container_user} --chmod=771 ./entrypoint.sh ${work_dir}/entrypoint.sh | ||
COPY --chown=${container_user}:${container_user} ./build_files/ ${work_dir} | ||
|
||
# set working directory | ||
WORKDIR ${work_dir} | ||
|
||
ENTRYPOINT ["/bin/bash", "-c", "./entrypoint.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,4 @@ | ||
#!/bin/bash | ||
|
||
java --version | ||
java -jar adminui-*-jar-with-dependencies.jar |