Skip to content

Commit

Permalink
Merge pull request #3 from kuafuai/feat/ci
Browse files Browse the repository at this point in the history
Feat/ci
  • Loading branch information
yakeJiang authored Oct 10, 2023
2 parents 23c8911 + 0ff00e9 commit 747eda9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ jobs:
cache: maven
- name: Build with Maven
run: mvn clean package
- name: Run Docker Build Script
env:
DOCKER_USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKER_REPO: ${{ vars.DOCKERHUB_REPO }}
run: |
chmod +x docker-build.sh
./docker-build.sh
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM openjdk:8-jdk-alpine

RUN mkdir -p /data/app

COPY target/empty_backend-1.0-SNAPSHOT.jar /data/app/app.jar

WORKDIR /data/app

EXPOSE 8086

CMD ["java","-jar","app.jar"]
16 changes: 16 additions & 0 deletions docker-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Get the current commit SHA
COMMIT_SHA=$(git rev-parse HEAD)

# Build the Docker image
docker build -t ${DOCKER_REPO}:${COMMIT_SHA} -t ${DOCKER_REPO}:latest -f Dockerfile .

# Login to Docker Hub
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin

# Push the Docker image
docker push ${DOCKER_REPO}:${COMMIT_SHA}
docker push ${DOCKER_REPO}:latest

echo "kuafuai_docker_image_pushed:${DOCKER_REPO}:${COMMIT_SHA}"

0 comments on commit 747eda9

Please sign in to comment.