diff --git a/backend/Jenkinsfile b/backend/Jenkinsfile new file mode 100644 index 0000000..6511ee8 --- /dev/null +++ b/backend/Jenkinsfile @@ -0,0 +1,44 @@ +pipeline { + agent any + stages { + stage("Clean workspace") { + cleanWs() + checkout scm + } + stage("Build backend") { + environment { + PATH = "/var/lib/jenkins/.cargo/bin:${env.PATH}" + } + steps { + sh "touch .env" + sh "echo DATABASE_URL=mysql://educa7ls_user:123456789a*@md-89.webhostbox.net:3306/educa7ls_plataforma >> .env" + sh "echo RENIEC_API=apis-token-1.aTSI1U7KEuT-6bbbCguH-4Y8TI6KS73N >> .env" + + sh "cargo build --release" + } + } + stage("Prepare docker") { + steps { + dir("docker") { + sh "touch .env" + sh "echo DATABASE_URL=mysql://educa7ls_user:123456789a*@md-89.webhostbox.net:3306/educa7ls_plataforma >> .env" + sh "echo RENIEC_API=apis-token-1.aTSI1U7KEuT-6bbbCguH-4Y8TI6KS73N >> .env" + sh "echo CLASSROOM_URL=https://aulavirtual.eegsac.com >> .env" + sh "echo CLASSROOM_USER=admin >> .env" + sh '''echo CLASSROOM_PASSWORD=YVL1@N4_PaL0-93\\$ >> .env''' + sh "echo RUST_LOG=info >> .env" + } + + sh "cp ./target/release/backend ./docker" + } + } + stage("Start docker") { + steps { + dir("docker") { + sh "docker compose stop" + sh "docker compose up --build" + } + } + } + } +} diff --git a/backend/docker/Dockerfile b/backend/docker/Dockerfile new file mode 100644 index 0000000..775e5a6 --- /dev/null +++ b/backend/docker/Dockerfile @@ -0,0 +1,16 @@ +## This dockerfile just creates an image for the backend binary +## to run on. + +## This Dockerfile expects on this same directory: +## - The backend binary +## - The .env file + +# Copy the binary into the image +COPY backend . +# Copy the generated env file +COPY .env . + +EXPOSE 8000 + +# Run the binary, the default Rocket port is 8000 +CMD ["./backend"] diff --git a/backend/docker/docker-compose.yaml b/backend/docker/docker-compose.yaml new file mode 100644 index 0000000..10ea4f7 --- /dev/null +++ b/backend/docker/docker-compose.yaml @@ -0,0 +1,11 @@ +version: '3' + +services: + com.eegsac.system: + container_name: com.eegsac.system + build: + context: . + dockerfile: Dockerfile + ports: + - "3333:8000" + restart: unless-stopped