[BE] Jenkinsfile to build & run backend with docker

This commit is contained in:
fernando 2024-02-01 12:02:10 -05:00
parent 399fd71c13
commit 074435ddce
3 changed files with 71 additions and 0 deletions

44
backend/Jenkinsfile vendored Normal file
View File

@ -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"
}
}
}
}
}

16
backend/docker/Dockerfile Normal file
View File

@ -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"]

View File

@ -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