music-to-go/Jenkinsfile

56 lines
1.1 KiB
Plaintext
Raw Normal View History

2024-10-07 01:29:28 +00:00
pipeline {
2024-10-07 01:45:54 +00:00
agent any
2024-10-07 01:29:28 +00:00
stages {
2024-10-27 23:17:22 +00:00
stage('Build templ files') {
sh 'docker run -v `pwd`:/app -w=/app ghcr.io/a-h/templ:latest generate'
}
2024-10-27 22:58:26 +00:00
stage('Build go binary') {
agent {
docker {
2024-10-27 23:17:22 +00:00
image 'golang:1.22-alpine3.20'
2024-10-27 22:58:26 +00:00
reuseNode true
}
}
steps {
2024-10-27 23:03:35 +00:00
sh 'go install github.com/a-h/templ/cmd/templ@latest'
2024-10-27 22:58:26 +00:00
sh 'go mod tidy'
2024-10-27 23:03:35 +00:00
sh 'templ generate'
2024-10-27 22:58:26 +00:00
sh 'go build main.go'
}
}
stage('Build static assets') {
agent {
docker {
image 'node:22'
reuseNode true
}
}
steps {
sh 'npm i -g pnpm'
sh 'pnpm i'
sh 'pnpm build'
}
}
2024-10-07 01:45:54 +00:00
stage('Populate env') {
2024-10-07 01:46:48 +00:00
steps {
sh 'rm .env || true'
2024-10-07 02:50:00 +00:00
sh 'echo "PORT=8007" >> .env'
2024-10-07 02:59:20 +00:00
sh 'echo "DB_HOST=music-to-go-db" >> .env'
2024-10-07 02:50:00 +00:00
sh 'echo "DB_PORT=5432" >> .env'
sh 'echo "DB_DATABASE=music" >> .env'
sh 'echo "DB_USERNAME=root" >> .env'
sh 'echo "DB_PASSWORD=root" >> .env'
sh 'echo "DB_SCHEMA=public" >> .env'
2024-10-07 01:46:48 +00:00
}
2024-10-07 01:45:54 +00:00
}
2024-10-07 01:29:28 +00:00
stage('Profit') {
steps {
dir('docker') {
2024-10-07 02:51:45 +00:00
sh 'docker-compose down || true'
2024-10-07 02:17:34 +00:00
sh 'docker-compose up -d --build'
}
2024-10-07 01:29:28 +00:00
}
}
}
}