This repository has been archived by the owner on Mar 21, 2024. It is now read-only.
-
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.
- Loading branch information
Showing
5 changed files
with
101 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: ci | ||
|
||
# Trigger event on every push / delete event, no matter the branch | ||
# on: [push, delete] | ||
|
||
# Trigger event on every push / delete event, only in master branch | ||
on: | ||
push: | ||
branches: | ||
- "master" | ||
delete: | ||
branches: | ||
- "master" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ secrets.DOCKERHUB_USERNAME }}/book-a-book-eureka:latest |
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 @@ | ||
# Use the UBI minimal base image for the compilation stage | ||
FROM openjdk:17-oracle as build | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Install necessary dependencies for compilation | ||
RUN microdnf install --nodocs -y java-17-openjdk-headless maven && \ | ||
microdnf clean all | ||
|
||
# Copy the source code to the container | ||
COPY . /app | ||
|
||
# Apply permissions | ||
RUN chown -R 1001:1001 /app | ||
|
||
# Set the user to run the application | ||
USER 1001 | ||
|
||
# Compile project skipping testing goals (compilation, resources and run of tests) | ||
RUN JAVA_HOME= ./mvnw clean package spring-boot:repackage -Dmaven.test.skip=true | ||
|
||
|
||
# Use the UBI minimal base image for the run stage | ||
FROM openjdk:17-oracle | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Install necessary dependencies for running | ||
RUN microdnf install --nodocs -y java-17-openjdk-headless && \ | ||
microdnf clean all | ||
|
||
# Copy the directory created in the first stage into the run container | ||
RUN mkdir -p /app/target | ||
COPY --from=build /app/target/book-a-book-eureka.jar /app | ||
|
||
# Cambia la propiedad del directorio '/app/target' al usuario con id 1001 | ||
RUN chown 1001:1001 /app/book-a-book-eureka.jar | ||
|
||
# Cambia el usuario que va a ejecutar los siguientes comandos al usuario con id 1001 | ||
USER 1001 | ||
|
||
ENTRYPOINT ["java", \ | ||
"-jar", "book-a-book-eureka.jar"] |
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,9 @@ | ||
# book-a-book-eureka | ||
Stores the Eureka server for the book a book application | ||
|
||
|
||
## One liner (build and redeploy with explicit push) | ||
You need a token against the user in dockerhub to be able to do an explicit push | ||
```shell | ||
sudo docker build -t aleixmt/book-a-book-eureka:latest . && sudo docker push aleixmt/book-a-book-eureka:latest && sudo docker-compose down && sudo docker-compose up -d | ||
``` |
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,8 @@ | ||
--- | ||
version: "2.1" | ||
services: | ||
book-a-book-eureka: | ||
image: aleixmt/book-a-book-eureka:latest | ||
ports: | ||
- "0.0.0.0:8762:8761" | ||
restart: unless-stopped |
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