-
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.
chore: add action to build and deploy
- Loading branch information
Showing
9 changed files
with
93 additions
and
214 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,3 @@ | ||
**/target | ||
**/.env | ||
.idea |
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,57 @@ | ||
name: publish | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
name: publish image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
deploy: | ||
needs: build-and-push-image | ||
name: deploy image | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Install ssh keys | ||
run: | | ||
install -m 600 -D /dev/null ~/.ssh/id_rsa | ||
echo "${{ secrets.DEPLOY_PRIVATE_KEY }}" > ~/.ssh/id_rsa | ||
ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} > ~/.ssh/known_hosts | ||
ssh-keyscan -H ${{ secrets.DEPLOY_JUMP_HOST }} > ~/.ssh/known_hosts | ||
- name: Connect and pull | ||
run: ssh -J ${{ secrets.DEPLOY_JUMP_USERNAME }}@${{ secrets.DEPLOY_JUMP_HOST }} ${{ secrets.DEPLOY_USERNAME }}@${{ secrets.DEPLOY_HOST }} \ | ||
"cd ${{ secrets.DEPLOY_PATH }} && docker compose pull && docker compose up -d && exit" | ||
|
||
- name: Cleanup | ||
run: rm -rf ~/.ssh |
This file was deleted.
Oops, something went wrong.
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,24 @@ | ||
## Stage 1 : build with maven builder image with native capabilities | ||
FROM quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-17 AS build | ||
COPY --chown=quarkus:quarkus . /code | ||
USER quarkus | ||
|
||
WORKDIR /code | ||
RUN ./mvnw -B org.apache.maven.plugins:maven-dependency-plugin:go-offline | ||
RUN ./mvnw package -DskipTests -Dnative | ||
|
||
## Stage 2 : create the docker final image | ||
FROM quay.io/quarkus/quarkus-micro-image:2.0 AS final | ||
WORKDIR /work/ | ||
COPY --from=build /code/interweb-server/target/*-runner /work/application | ||
|
||
# set up permissions for user `1001` | ||
RUN chmod 775 /work /work/application \ | ||
&& chown -R 1001 /work \ | ||
&& chmod -R "g+rwX" /work \ | ||
&& chown -R 1001:root /work | ||
|
||
EXPOSE 8080 | ||
USER 1001 | ||
|
||
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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