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
6 changed files
with
158 additions
and
0 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,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-operador: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,48 @@ | ||
# 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-operador.jar /app | ||
|
||
# Cambia la propiedad del directorio '/app/target' al usuario con id 1001 | ||
RUN chown 1001:1001 /app/book-a-book-operador.jar | ||
|
||
# Cambia el usuario que va a ejecutar los siguientes comandos al usuario con id 1001 | ||
USER 1001 | ||
|
||
# Set the application profile in order to change the config of DB location | ||
ENV spring_profiles_active=prod | ||
|
||
ENTRYPOINT ["java", \ | ||
"-jar", "book-a-book-operador.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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
version: "2.1" | ||
services: | ||
book-a-book-buscador: | ||
image: aleixmt/book-a-book-buscador:latest | ||
ports: | ||
- "0.0.0.0:8082:8081" | ||
#restart: unless-stopped | ||
|
||
book-a-book-operador: | ||
image: aleixmt/book-a-book-operador:latest | ||
ports: | ||
- "0.0.0.0:8084:8083" | ||
#restart: unless-stopped | ||
|
||
postgres_db: | ||
image: postgres | ||
environment: | ||
- PUID=1001 | ||
- PGID=1001 | ||
- TZ=Etc/UTC | ||
- POSTGRES_PASSWORD=chemistry | ||
- POSTGRES_USER=aleixmt | ||
- POSTGRES_DB=book-a-book-operador | ||
ports: | ||
- "0.0.0.0:5433:5432" | ||
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
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,21 @@ | ||
#################################### | ||
### SETTING UP CONNECTION TO DB #### | ||
#################################### | ||
|
||
# Set connection to the desired table of DB using URL | ||
spring.datasource.url=jdbc:postgresql://localhost:5432/bookabook | ||
|
||
# Database credentials | ||
spring.datasource.username=aleixmt | ||
spring.datasource.password=chemistry | ||
|
||
# Default policy with database contents when booting: "validate" checks consistency, "create" wipes colliding tables and creates | ||
# them from scratch, "create-drop" creates DB schema and then drops the information. "Update" updates the information. | ||
# "None" does nothing | ||
spring.jpa.hibernate.ddl-auto=update | ||
|
||
# Output the SQL queries | ||
spring.jpa.show-sql=true | ||
# Format of the SQL queries written in the output | ||
spring.jpa.properties.hibernate.format_sql=true | ||
|
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,21 @@ | ||
#################################### | ||
### SETTING UP CONNECTION TO DB #### | ||
#################################### | ||
|
||
# Set connection to the desired table of DB using URL | ||
spring.datasource.url=jdbc:postgresql://postgres_db:5432/book-a-book-operador | ||
|
||
# Database credentials | ||
spring.datasource.username=aleixmt | ||
spring.datasource.password=chemistry | ||
|
||
# Default policy with database contents when booting: "validate" checks consistency, "create" wipes colliding tables and creates | ||
# them from scratch, "create-drop" creates DB schema and then drops the information. "Update" updates the information. | ||
# "None" does nothing | ||
spring.jpa.hibernate.ddl-auto=update | ||
|
||
# Output the SQL queries | ||
spring.jpa.show-sql=true | ||
# Format of the SQL queries written in the output | ||
spring.jpa.properties.hibernate.format_sql=true | ||
|