Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6e36da2
Flex Shape
AdanRuiz Feb 28, 2024
9e88f9f
Flex OL 8
AdanRuiz Feb 29, 2024
433966c
aarch64 for graalvm
AdanRuiz Mar 1, 2024
3badff6
DB free tier
AdanRuiz Mar 6, 2024
b9822d3
Token Cretaion wait
AdanRuiz Mar 6, 2024
838795c
Deploy pwd
AdanRuiz Mar 13, 2024
da52425
Destroy mv folders
AdanRuiz Mar 14, 2024
e696422
Destroy mv log files
AdanRuiz Mar 14, 2024
8c05898
Destroy Rec.
AdanRuiz Mar 14, 2024
030b95a
Compartment Removal msg
AdanRuiz Mar 14, 2024
279050d
kubernetes version
AdanRuiz Apr 11, 2024
7f7d2b0
nodepool version
AdanRuiz Apr 11, 2024
5fc1f15
state example
AdanRuiz Jun 5, 2024
93aac51
devops
AdanRuiz Jun 5, 2024
e746867
DevOps1
AdanRuiz Jun 6, 2024
36bd38a
devops2
AdanRuiz Jun 6, 2024
b731f40
devops 2
AdanRuiz Jun 12, 2024
104aa60
DevOps 3
AdanRuiz Jun 12, 2024
a7adeec
DevOps4
AdanRuiz Jun 12, 2024
aa53e68
Docker Login Support
AdanRuiz Jun 12, 2024
373585c
DevOps 5
AdanRuiz Jun 12, 2024
4cd07b2
DevOps6
AdanRuiz Jun 12, 2024
7014b74
k8s version
AdanRuiz Aug 13, 2024
1e02589
k8s version
AdanRuiz Aug 13, 2024
638953f
node shape
AdanRuiz Aug 22, 2024
af3050d
Image - Shape Compatibility
AdanRuiz Aug 22, 2024
ad7fece
Bug NS
AdanRuiz Aug 22, 2024
b4a7a5f
shape
AdanRuiz Aug 22, 2024
1b29e3b
namespace bug
AdanRuiz Aug 26, 2024
2bccee4
x86
AdanRuiz Aug 27, 2024
31f5a27
Extra Validations
AdanRuiz Aug 27, 2024
c4b2e41
Destroy advise
AdanRuiz Aug 27, 2024
9a2d93f
image regex
AdanRuiz Sep 3, 2024
61cb883
Cambios a archivos para run local, presenta error con DB
Gabo8912 Mar 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions MtdrSpring/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM openjdk:11
COPY pom.xml /tmp/
COPY src /tmp/src/
FROM openjdk:22
#COPY pom.xml /tmp/
#COPY src /tmp/src/
WORKDIR /tmp/
EXPOSE 8080
COPY target/MyTodoList-0.0.1-SNAPSHOT.jar MyTodoList.jar
Expand Down
8 changes: 4 additions & 4 deletions MtdrSpring/backend/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ export IMAGE_VERSION=0.1


if [ -z "$DOCKER_REGISTRY" ]; then
echo "DOCKER_REGISTRY not set. Will get it with state_get"
export DOCKER_REGISTRY=$(state_get DOCKER_REGISTRY)
export DOCKER_REGISTRY=$(state_get DOCKER_REGISTRY)
echo "DOCKER_REGISTRY set."
fi

if [ -z "$DOCKER_REGISTRY" ]; then
echo "Error: DOCKER_REGISTRY env variable needs to be set!"
exit 1
fi

export IMAGE=${DOCKER_REGISTRY}/${IMAGE_NAME}:${IMAGE_VERSION}

mvn clean package spring-boot:repackage
docker build -f Dockerfile -t $IMAGE .

docker push $IMAGE
if [ $? -eq 0 ]; then
docker rmi "$IMAGE"
docker rmi "$IMAGE" #local
fi
21 changes: 16 additions & 5 deletions MtdrSpring/backend/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
#!/bin/bash
SCRIPT_DIR=$(dirname $0)
SCRIPT_DIR=$(pwd)

#Validation
if [ -z "$DOCKER_REGISTRY" ]; then
export DOCKER_REGISTRY=$(state_get DOCKER_REGISTRY)
echo "DOCKER_REGISTRY set."
fi
if [ -z "$DOCKER_REGISTRY" ]; then
echo "Error: DOCKER_REGISTRY env variable needs to be set!"
exit 1
fi

if [ -z "$TODO_PDB_NAME" ]; then
echo "TODO_PDB_NAME not set. Will get it with state_get"
export TODO_PDB_NAME=$(state_get MTDR_DB_NAME)
export TODO_PDB_NAME=$(state_get MTDR_DB_NAME)
echo "TODO_PDB_NAME set."
fi
if [ -z "$TODO_PDB_NAME" ]; then
echo "Error: TODO_PDB_NAME env variable needs to be set!"
exit 1
fi

if [ -z "$OCI_REGION" ]; then
echo "OCI_REGION not set. Will get it with state_get"
export OCI_REGION=$(state_get REGION)
Expand All @@ -19,9 +31,8 @@ fi

if [ -z "$UI_USERNAME" ]; then
echo "UI_USERNAME not set. Will get it with state_get"
export UI_USERNAME=$(state_get UI_USERNAME)
export UI_USERNAME=$(state_get UI_USERNAME)
fi

if [ -z "$UI_USERNAME" ]; then
echo "Error: UI_USERNAME env variable needs to be set!"
exit 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ public class OracleConfiguration {
@Bean
public DataSource dataSource() throws SQLException{
OracleDataSource ds = new OracleDataSource();
ds.setDriverType(env.getProperty("driver_class_name"));
/* ds.setDriverType(env.getProperty("driver_class_name"));
logger.info("Using Driver " + env.getProperty("driver_class_name"));
ds.setURL(env.getProperty("db_url"));
logger.info("Using URL: " + env.getProperty("db_url"));
ds.setUser(env.getProperty("db_user"));
logger.info("Using Username " + env.getProperty("db_user"));
ds.setPassword(env.getProperty("dbpassword"));
ds.setPassword(env.getProperty("dbpassword")); */
// For local testing
// ds.setDriverType(dbSettings.getDriver_class_name());
// logger.info("Using Driver " + dbSettings.getDriver_class_name());
// ds.setURL(dbSettings.getUrl());
// logger.info("Using URL: " + dbSettings.getUrl());
// ds.setUser(dbSettings.getUsername());
// logger.info("Using Username: " + dbSettings.getUsername());
// ds.setPassword(dbSettings.getPassword());
ds.setDriverType(dbSettings.getDriver_class_name());
logger.info("Using Driver " + dbSettings.getDriver_class_name());
ds.setURL(dbSettings.getUrl());
logger.info("Using URL: " + dbSettings.getUrl());
ds.setUser(dbSettings.getUsername());
logger.info("Using Username: " + dbSettings.getUsername());
ds.setPassword(dbSettings.getPassword());
return ds;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ToDoItemController {
public List<ToDoItem> getAllToDoItems(){
return toDoItemService.findAll();
}
//@CrossOrigin
//@CrossOriginFailed to load resource: the server responded with a status of 500 ()
@GetMapping(value = "/todolist/{id}")
public ResponseEntity<ToDoItem> getToDoItemById(@PathVariable int id){
try{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.springboot.MyTodoList.security;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
Expand All @@ -12,8 +11,9 @@
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity.csrf().disable();
httpSecurity.authorizeRequests().anyRequest().authenticated().and().
formLogin().and().logout().permitAll();
httpSecurity
.csrf(csrf -> csrf.disable())
.authorizeRequests(requests -> requests
.antMatchers("/**").permitAll());
}
}
18 changes: 11 additions & 7 deletions MtdrSpring/backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#spring.jpa.database-platform=org.hibernate.dialect.Oracle12cDialect
#oracle.jdbc.fanEnabled=false
##this is not used when deployed in kubernetes. Just for local testing
#spring.datasource.url=jdbc:oracle:thin:@adbps_medium?TNS_ADMIN=/Users/psong/Downloads/Wallet_ADBPS
#spring.datasource.username=admin
#spring.datasource.password=WELcome__12345
spring.datasource.url=jdbc:oracle:thin:@oraclebotdbteam16_high?TNS_ADMIN=D:/TECMTY/SEMESTRE_7(6)/Oracle_(Oswaldo)/RETO/oci-react-samples/wallet
spring.datasource.username=TODOUSER
spring.datasource.password=VizcaBarca10$

##Properties of UCP
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
Expand All @@ -16,12 +16,16 @@ spring.datasource.oracleucp.min-pool-size=10
spring.datasource.oracleucp.max-pool-size=30

##Logging properties for UCP
logging.level.root=trace
#logging.level.root=trace
logging.file.name=logs.log
logging.level.oracle.ucp=trace
#logging.level.oracle.ucp=trace

#spring.security.user.name=psong
#spring.security.user.password=WELcome__12345

#telegram.bot.token=<TELEGRAM_BOT_TOKEN>
#telegram.bot.name=<TELEGRAM_BOT_NAME>
telegram.bot.token=7259037295:AAH8hLPfs8Q5ISfgb7mqGrenKPb_aWYMMOQ
telegram.bot.name=team_16_java_bot

# optional, this changes the port of the development server
# set to whatever you need
server.port=8081
16 changes: 15 additions & 1 deletion MtdrSpring/destroy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,18 @@ fi

$MTDRWORKSHOP_LOCATION/utils/main-destroy.sh

cd
deleteDir=toDelete_$(date +%Y%m%d_%H%M%S)
mkdir $deleteDir
mv state $deleteDir
mv tls $deleteDir
mv wallet $deleteDir
mv log $deleteDir

echo 'Recommendations:'
echo ' 1. Manually rename compartment'
echo ' 2. Manually check/remove OKE cluster from compartment'
echo ' 3. Manually check/remove Auth Tokens'
echo ' 4. Manually check/remove Buckets from compartment'
echo ' 5. Manually check/remove Compute Instances from compartment'
echo ' 6. Manually check/remove ATP DB from compartment'
echo ' 7. Try remove compartment elements through Tenancy Explorer'
26 changes: 17 additions & 9 deletions MtdrSpring/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,32 @@ function sed_i(){
}
export -f sed_i

# Java Home
# -d true if file is a directory, so it's testing if this directory exists, if it does
# we are on Mac doing local dev
function set_javahome(){
if test -d ~/graalvm-ce-java11-20.1.0/Contents/Home/bin; then
# We are on Mac doing local dev
export JAVA_HOME=~/graalvm-ce-java11-20.1.0/Contents/Home;
else
# Assume linux
export JAVA_HOME=~/graalvm-ce-java11-20.1.0
fi
export PATH=$JAVA_HOME/bin:$PATH
}

#set mtdrworkshop_location
export MTDRWORKSHOP_LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd $MTDRWORKSHOP_LOCATION
echo "MTDRWORKSHOP_LOCATION: $MTDRWORKSHOP_LOCATION"


# Java Home
# -d true if file is a directory, so it's testing if this directory exists, if it does
# we are on Mac doing local dev
if test -d ~/graalvm-ce-java11-20.1.0/Contents/Home/bin; then
# We are on Mac doing local dev
export JAVA_HOME=~/graalvm-ce-java11-20.1.0/Contents/Home;
JAVA_TEST=`which java`
if [ -n $JAVA_TEST ]; then
echo "JAVA Found: $JAVA_TEST"
else
# Assume linux
export JAVA_HOME=~/graalvm-ce-java11-20.1.0
set_javahome
fi
export PATH=$JAVA_HOME/bin:$PATH

#state directory
if test -d ~/mtdrworkshop-state; then
Expand Down
20 changes: 12 additions & 8 deletions MtdrSpring/terraform/containerengine.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ resource "oci_containerengine_cluster" "mtdrworkshop_cluster" {
]
subnet_id = oci_core_subnet.endpoint.id
}
kubernetes_version = "v1.28.2"
kubernetes_version = "v1.30.1"
name = "mtdrworkshopcluster-${var.mtdrKey}"
vcn_id = oci_core_vcn.okevcn.id
#optional
Expand Down Expand Up @@ -36,12 +36,14 @@ resource "oci_containerengine_node_pool" "oke_node_pool" {
#Required
cluster_id = oci_containerengine_cluster.mtdrworkshop_cluster.id
compartment_id = var.ociCompartmentOcid
kubernetes_version = "v1.28.2"
kubernetes_version = "v1.30.1"
name = "Pool"
# node_shape="VM.Standard2.4"
# node_shape = "VM.Standard.B2.1"
node_shape = "VM.Standard.E2.1"
# node_shape = "VM.Standard2.2"
#node_shape = "VM.Standard.A1.Flex" #Always Free Option
node_shape = "VM.Standard.E3.Flex"
node_shape_config {
memory_in_gbs = 6
ocpus = 2
}
#subnet_ids = [oci_core_subnet.nodePool_Subnet_1.id]
#Optional
node_config_details {
Expand All @@ -68,7 +70,7 @@ resource "oci_containerengine_node_pool" "oke_node_pool" {
#boot_volume_size_in_gbs = "60"
}
//quantity_per_subnet = 1
//ssh_public_key = var.node_pool_ssh_public_key
//ssh_public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsXyGATqdTnvEDe0aYHGL+QQDjUXf6EIBlKiNLYR4gZhStp4yfn/MEWmCMGg3cbne04HlaeO3zGrUnrtfAQE90XccW9Dc4WkhLYf2vucja9NezAVQZE2qBYiwdZSF9G/FwPI1DzfbXF2UAAN3ix/IwJSWN3KZnd1FOcHOA052QMa7jGOIbi8+skKqkys3gcTaor7eXe/wONimkpPevF30FTQZpsQFU7ZzYcFM3C+XVZ2/UVtZ/MaDf73ub6mYNMpDtDCTMo9FyujzK84EKWIytAKofNwJ/Og3Wqr+CKAeLgCMtWp0926w+ff8dJRDuOxlxgJB48YaFSvjIr4lAv/aX rafael_a_g@6ab23190fb98"
//ssh_public_key = var.resUserPublicKey
}
data "oci_containerengine_cluster_option" "mtdrworkshop_cluster_option" {
Expand All @@ -79,5 +81,7 @@ data "oci_containerengine_node_pool_option" "mtdrworkshop_node_pool_option" {
}
locals {
all_sources = data.oci_containerengine_node_pool_option.mtdrworkshop_node_pool_option.sources
oracle_linux_images = [for source in local.all_sources : source.image_id if length(regexall("Oracle-Linux-[0-9]*.[0-9]*-20[0-9]*",source.source_name)) > 0]
#oracle_linux_images = [for source in local.all_sources : source.image_id if length(regexall("Oracle-Linux-[0-9]*.[0-9]*-aarch64-20[0-9]*",source.source_name)) > 0] #ARM Option
oracle_linux_images = [for source in local.all_sources : source.image_id if length(regexall("Oracle-Linux-[0-9]*.[0-9]*-20[0-9]*.*1.30.1",source.source_name)) > 0]

}
2 changes: 1 addition & 1 deletion MtdrSpring/terraform/database.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ resource "oci_database_autonomous_database" "autonomous_database_atp" {
data_storage_size_in_tbs = "1"
db_name = var.mtdrDbName
# is_free_tier = true , if there exists sufficient service limit
is_free_tier = false
is_free_tier = true
#Optional #db_workload = "${var.autonomous_database_db_workload}"
db_workload = var.autonomous_database_db_workload
display_name ="MTDRDB"
Expand Down
2 changes: 1 addition & 1 deletion MtdrSpring/terraform/object_storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ data oci_objectstorage_namespace namespace {

resource "oci_objectstorage_bucket" dbbucket {
#Required
namespace = data.oci_objectstorage_namespace.namespace.namespace
compartment_id = var.ociCompartmentOcid
name = "${var.runName}-${var.mtdrKey}"
namespace = data.oci_objectstorage_namespace.namespace.namespace
}
1 change: 1 addition & 0 deletions MtdrSpring/utils/java-builds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ while ! state_done GRAAL; do
if ! test -d ~/graalvm-ce-java11-20.1.0; then
echo "downloading graalVM"
curl -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-20.1.0/graalvm-ce-java11-linux-amd64-20.1.0.tar.gz | tar xz
#curl -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-20.1.0/graalvm-ce-java11-linux-aarch64-20.1.0.tar.gz | tar xz
mv graalvm-ce-java11-20.1.0 ~/
fi
state_set_done GRAAL
Expand Down
4 changes: 3 additions & 1 deletion MtdrSpring/utils/main-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ while ! state_done COMPARTMENT_OCID; do
fi
while ! test `oci iam compartment get --compartment-id "$COMPARTMENT_OCID" --query 'data."lifecycle-state"' --raw-output 2>/dev/null`"" == 'ACTIVE'; do
echo "Waiting for the compartment to become ACTIVE"
sleep 2
sleep 60
done
state_set COMPARTMENT_OCID "$COMPARTMENT_OCID"
done
Expand Down Expand Up @@ -162,6 +162,7 @@ while ! state_done DOCKER_REGISTRY; do
if test $(state_get RUN_TYPE) -ne 3; then
##export OCI_CLI_PROFILE=$(state_get HOME_REGION) ## have to get rid of this for non instance_principal based stuff
if ! TOKEN=`oci iam auth-token create --user-id "$(state_get USER_OCID)" --description 'mtdr docker login' --query 'data.token' --raw-output 2>$MTDRWORKSHOP_LOG/docker_registry_err`; then
sleep 60
if grep UserCapacityExceeded $MTDRWORKSHOP_LOG/docker_registry_err >/dev/null; then
# The key already exists
echo 'ERROR: Failed to create auth token. Please delete an old token from the OCI Console (Profile -> User Settings -> Auth Tokens).'
Expand All @@ -172,6 +173,7 @@ while ! state_done DOCKER_REGISTRY; do
cat $MTDRWORKSHOP_LOG/docker_registry_err
exit
fi
sleep 5
fi
else
read -s -r -p "Please generate an Auth Token and enter the value: " TOKEN
Expand Down
37 changes: 37 additions & 0 deletions oci_devops.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: 0.1
component: build
timeoutInSeconds: 600
shell: bash

env:
variables:
JAVA_HOME: /usr/lib64/graalvm/graalvm22-ee-java17

exportedVariables:
- BuildServiceDemoVersion

steps:
- type: Command
name: "Install GraalVM Enterprise 22.x Native Image for Java17"
command: yum -y install graalvm22-ee-17-native-image

- type: Command
name: "Set PATH Variable"
command: export PATH=$JAVA_HOME/bin:$PATH

- type: Command
name: "Docker Login"
command: cd MtdrSpring;
oci os object get --bucket-name reacttodo-rolax --name deployment_config.tgz --file deployment_config.tgz;
tar -xzvf deployment_config.tgz;
source env.sh;
cat at.cfg | docker login -u "axzmghqes1gn/[email protected]" --password-stdin mx-queretaro-1.ocir.io

- type: Command
name: "Build"
command: cd MtdrSpring;
source env.sh;
(cd backend;source build.sh)



Loading