Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
9afc77c
Terraform workflows trigger path update
WallyS02 Apr 26, 2025
1b26843
Added secret Terraform values preparation to Terraform workflows
WallyS02 Apr 26, 2025
a4c0655
Terraform workflows refactor
WallyS02 Apr 26, 2025
f3ca17a
Terraform workflows value file creation fix
WallyS02 Apr 26, 2025
5e71911
Terraform workflows value file creation text formatting fix
WallyS02 Apr 26, 2025
8885fd6
Changed NAT Instance SSH key pair usage to SSM
WallyS02 Apr 26, 2025
dcb792c
Terraform plan workflow debugged
WallyS02 Apr 26, 2025
4dd9d22
Prevented application pipelines from running unnecessary jobs on pull…
WallyS02 Apr 27, 2025
d7b0b88
Divided SonarCloud analysis to separate backend and frontend analysis
WallyS02 Apr 27, 2025
6e5d432
Fix exporting environment variables, changed cache usage, added share…
WallyS02 Apr 27, 2025
e9a0065
Changed deprecated Sonar Cloud action, added installing cached npm de…
WallyS02 Apr 27, 2025
39b5428
Changed running frontend application to allowed port
WallyS02 Apr 27, 2025
cd44454
Cypress wait-on port fix, configured Lighthouse to upload artifact, d…
WallyS02 Apr 27, 2025
40be767
Cypress wait-on api typo fix
WallyS02 Apr 27, 2025
d6ca5b5
Cypress config-file path fix, Docker build and push context fix
WallyS02 Apr 27, 2025
61ef646
Fixed Docker registry tag environment variable, removed backend depen…
WallyS02 Apr 27, 2025
49fbc53
Prepared frontend pipeline for main branch, fixed running Django test…
WallyS02 Apr 27, 2025
80ff8b1
Adjusted ECR lifecycle policy, fixed authenticating to AWS ECR
WallyS02 Apr 27, 2025
1bc6b82
Prepared backend pipeline for main branch, changed Secrets Manager us…
WallyS02 Apr 27, 2025
7dbd75f
SSM secret parameter module usage path fix
WallyS02 Apr 27, 2025
107596b
SSM secret parameter permissions fixes, prepared Terraform apply pipe…
WallyS02 Apr 27, 2025
2a848ca
TESTING change, to be replaced after debug
WallyS02 Apr 27, 2025
7e87623
Terraform files format
WallyS02 Apr 27, 2025
38f3be7
Django backend pipeline testing conditions
WallyS02 Apr 28, 2025
18effa2
Django backend pipeline testing
WallyS02 Apr 28, 2025
1f8207d
Django backend pipeline testing
WallyS02 Apr 28, 2025
4d7a79d
Django backend pipeline testing
WallyS02 Apr 28, 2025
8dfffe9
Prepared backend pipeline for main branch, fixed SSM usage in NAT ins…
WallyS02 Apr 28, 2025
220ca84
Added backend's local GitLab CI/CD pipeline using gitlab-ci-local, fi…
WallyS02 May 6, 2025
1b5fc43
Updated previous commit fixes.
WallyS02 May 6, 2025
b02710e
Added GitLab CI/CD pipeline for building, publishing and upgrading ne…
WallyS02 May 6, 2025
7eba64c
Added frontend's local GitLab CI/CD pipeline, other pipeline typo fixes
WallyS02 May 6, 2025
f91cc81
Update README.md
WallyS02 May 6, 2025
e2a6333
Added important directories and files description to README
WallyS02 May 7, 2025
2b7a41d
Updated roadmap in README
WallyS02 May 7, 2025
ef165fc
Unused docker-compose cleanup
WallyS02 May 8, 2025
a480a20
First version of backend's Jenkinsfile
WallyS02 May 8, 2025
d9ffb21
Backend Jenkinsfile fixes
WallyS02 May 8, 2025
298f12d
Backend Jenkinsfile agent fix
WallyS02 May 8, 2025
78c4246
Backend Jenkinsfile env fixes
WallyS02 May 8, 2025
323dec3
SonarQube backend Jenkinsfile fixes
WallyS02 May 8, 2025
06fb873
Sonar scanner fixes
WallyS02 May 8, 2025
f9952e6
Tools cleanup
WallyS02 May 8, 2025
7e2769d
Python fixes
WallyS02 May 8, 2025
38f416f
Accepting stage failures, triggering on changes in given directory
WallyS02 May 8, 2025
5ea2520
When fixes
WallyS02 May 8, 2025
324ddc6
When env refactor, added missing dev package
WallyS02 May 8, 2025
28f6b06
Syncing package.json and package-lock.json
WallyS02 May 8, 2025
8d026af
Comment to trigger run
WallyS02 May 8, 2025
119f86e
Enabled pulling dependencies
WallyS02 May 8, 2025
bd08e02
Running services debugging
WallyS02 May 8, 2025
1c34d46
Wait-on debugging
WallyS02 May 8, 2025
962265d
Added catchErrors
WallyS02 May 8, 2025
969024c
Wait-on address change
WallyS02 May 8, 2025
611fc19
Debugging e2e tests stage
WallyS02 May 8, 2025
9c80bbc
Comment for debugging
WallyS02 May 8, 2025
dd22e3b
E2E test debugging
WallyS02 May 8, 2025
c1346ec
Different Docker approach debugging
WallyS02 May 9, 2025
a6f5848
curl debugging
WallyS02 May 9, 2025
b92bf90
curl protocol fix
WallyS02 May 9, 2025
1fb2c4c
Added cleanup
WallyS02 May 9, 2025
3330527
Changed services to docker
WallyS02 May 9, 2025
dfd8670
Running docker command fixes
WallyS02 May 9, 2025
add4a7a
Changed withRun to run
WallyS02 May 9, 2025
a445a10
Docker network fixes
WallyS02 May 9, 2025
8719506
docker debugging
WallyS02 May 9, 2025
6a45c5b
docker debugging
WallyS02 May 9, 2025
0c2ec54
docker debugging
WallyS02 May 9, 2025
74d108a
env variables fix
WallyS02 May 9, 2025
2e14373
testing
WallyS02 May 9, 2025
35e0f82
backend run typo fixes
WallyS02 May 9, 2025
42540be
docker network fixes
WallyS02 May 9, 2025
48709fa
backend debugging
WallyS02 May 9, 2025
be144c7
syntax fixes
WallyS02 May 9, 2025
556e4be
docker debugging
WallyS02 May 9, 2025
6885dba
docker debugging
WallyS02 May 9, 2025
8c63bf3
docker debugging
WallyS02 May 9, 2025
4fc35f4
docker fixes
WallyS02 May 9, 2025
9a250dc
docker debugging
WallyS02 May 9, 2025
a4d6009
env variables fix
WallyS02 May 9, 2025
57f3ccf
typos fixes
WallyS02 May 9, 2025
b85b42b
permission fixes
WallyS02 May 9, 2025
617ed99
permissions fixes
WallyS02 May 9, 2025
2e97206
port and cypress fixes
WallyS02 May 9, 2025
ede069f
port and cypress fixes
WallyS02 May 9, 2025
6bd4ce3
typo fix
WallyS02 May 9, 2025
f0e59fd
docker network uncomment
WallyS02 May 9, 2025
72fc35b
network change
WallyS02 May 9, 2025
b7ed5da
moved locust to docker
WallyS02 May 9, 2025
b465d5b
test container debugging
WallyS02 May 10, 2025
a783753
test containers fixes
WallyS02 May 10, 2025
f0d8bd7
typo fixes
WallyS02 May 10, 2025
594e8aa
docker pipeline fixes
WallyS02 May 10, 2025
54e1a71
docker debugging
WallyS02 May 10, 2025
299f5c9
docker debugging
WallyS02 May 10, 2025
06e96df
test docker debugging
WallyS02 May 10, 2025
e2145a3
entrypoint debugging
WallyS02 May 10, 2025
8da5907
test containers debugging
WallyS02 May 10, 2025
96dac99
docker changed to agent
WallyS02 May 10, 2025
1e3b9a5
entrypoint fix
WallyS02 May 10, 2025
66fbfeb
container debugging
WallyS02 May 10, 2025
2a6ec15
sleep fixes
WallyS02 May 10, 2025
50aad89
debug
WallyS02 May 10, 2025
8647be1
cypress and locust fixes
WallyS02 May 10, 2025
669a15f
commented out unnessesary stage
WallyS02 May 10, 2025
8df0561
connectivity debugging
WallyS02 May 10, 2025
d9c1b7a
removed ping
WallyS02 May 10, 2025
37ef4d3
cypress changed to root
WallyS02 May 10, 2025
ff1af2d
curl testing
WallyS02 May 10, 2025
a4b34d6
apt-get fixes
WallyS02 May 10, 2025
14af59e
frontend port fix
WallyS02 May 10, 2025
ce6ea0c
cypress fixes
WallyS02 May 10, 2025
aed41ce
docker push debugging
WallyS02 May 10, 2025
452d80a
docker push debugging
WallyS02 May 10, 2025
2ec94c0
url docker hub change
WallyS02 May 10, 2025
d332301
helm deploy debugging
WallyS02 May 10, 2025
80df6ed
helm debugging
WallyS02 May 10, 2025
5ab09a1
Undebugged final version of backend Jenkinsfile
WallyS02 May 10, 2025
a3dbce3
Backend DAST tests debugging
WallyS02 May 10, 2025
7b23c65
Catch error change
WallyS02 May 10, 2025
069f0a0
Docker push variable fix
WallyS02 May 10, 2025
70dd756
Final backend Jenkinsfile
WallyS02 May 10, 2025
5b1e7b2
First version of frontend pipeline
WallyS02 May 10, 2025
df23b80
Lighthouse change
WallyS02 May 10, 2025
4215ff2
Lighthouse fixes
WallyS02 May 10, 2025
6ea2a61
lighthouse fixes
WallyS02 May 10, 2025
a4b7c98
Final frontend pipeline
WallyS02 May 10, 2025
e1a27af
Jenkinsfile stage tab indentation fix
WallyS02 May 10, 2025
8fa89a5
First version of chart update pipeline
WallyS02 May 10, 2025
9753c51
pipeline trigger comment
WallyS02 May 10, 2025
6318aec
Git config fixes
WallyS02 May 10, 2025
242a085
commented out unnessesary stages
WallyS02 May 10, 2025
919b54c
Updated publish script to use git config
WallyS02 May 10, 2025
e0365ff
Publish script fixes
WallyS02 May 10, 2025
3cb1741
Changed git config usage
WallyS02 May 10, 2025
9eeb7e8
Added GitHub Authentication
WallyS02 May 10, 2025
141607c
Authenticating jenkins
WallyS02 May 10, 2025
2854449
Final Helm Chart update pipeline
WallyS02 May 10, 2025
e01c2b2
Added local Jenkins configuration
WallyS02 May 10, 2025
c2411a4
Minikube restore fixes
WallyS02 May 10, 2025
b2972d8
Merge branch 'main' into cicd
WallyS02 May 10, 2025
905f867
Added jenkins directory description
WallyS02 May 10, 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
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ Make migrations and migrate
```bash
python manage.py makemigrations
python manage.py migrate
python manage.py loaddata api/fixtures/herbs.json
```
Run application
```
python manage.py runserver localhost:8080
python manage.py runserver 0.0.0.0:8080
```
Once the application is running, you can access it locally by navigating to http://localhost:8080.

Expand All @@ -70,13 +71,27 @@ Run the Development Server
```
This will start the development server, and you can access the application at http://localhost:80 in your web browser.

## Important directories and files
* **.github** - directory that contains GitHub Actions pipelines
* **aws** - directory that contains AWS cloud architecture for application and it's implementation using IaC practise with Terraform
* **backend** - directory that contains backend application code
* **documentation** - directory that contains application design and it's diagrams
* **frontend** - directory that contains frontend application code
* **jenkins** - directory that contains local Jenkins configuration files
* **k8s** - directory that contains raw Kubernetes manifests and Helm charts for application, also contains some utility bash scripts
* **.gitlab-ci.yml** - main GitLab CI/CD pipeline, which uses gitlab-ci-local, that triggers child pipelines located in backend, frontend and k8s subdirectories
* **docker-compose-local.yml** - docker-compose file that allows running application locally

## Roadmap
- [x] build project diagrams
- [x] build backend application
- [x] build frontend application
- [x] build docker deployment
- [ ] build github workflow cicd
- [x] prepare project design
- [x] create backend application
- [x] create frontend application
- [x] create Docker images
- [x] create Kubernetes (raw + Helm) deployment
- [x] prepare AWS cloud architecture
- [x] create example unit, integration, e2e and performance tests
- [x] create IaC Terraform configuration for application's AWS cloud
- [x] create GitHub Actions, GitLab CI/CD (gitlab-ci-local) and Jenkins CI/CD pipelines
- [x] complete final README
- [x] deploy application
## Authors
- [@WallyS02](https://github.com/WallyS02) everything
3 changes: 3 additions & 0 deletions backend/the_plug_backend_django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ RUN sed -i 's/\r$//' ./entrypoint.sh && \
chmod +x ./test-entrypoint.sh

RUN addgroup -S user && adduser -S user -G user

RUN chmod -R 700 . && chown -R user:user .

USER user

EXPOSE 8080
Expand Down
235 changes: 235 additions & 0 deletions backend/the_plug_backend_django/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
pipeline {
agent any

environment {
SONAR_TOKEN_BACKEND = credentials('sonar-token-backend')
DB_PASSWORD = credentials('db-password')
DB_USER = 'admin'
DB_NAME = 'postgres'
DB_HOST = 'localhost:5432'
EMAIL_HOST_PASSWORD = credentials('email-host-password')
EMAIL_HOST_USER = credentials('email-host-user')
SECRET_KEY = credentials('secret-key')
PGADMIN_DEFAULT_EMAIL = 'admin@admin.com'
PGADMIN_DEFAULT_PASSWORD = credentials('pgadmin-default-password')
ALLOWED_HOSTS = '*'
DEBUG = '1'
CACHE_ENDPOINT = 'no'
CACHE_PASSWORD = 'no'
USE_CACHE = '0'
DOCKER_REGISTRY = 'https://index.docker.io/v1/'
BACKEND_IMAGE = 'wallys02/the-plug-backend:latest'
PIP_CACHE_DIR = "${env.HOME}/.cache/pip"
NPM_CONFIG_CACHE = "${env.HOME}/.cache/npm"
KUBECONFIG = "${env.HOME}/.kube/config"
BACKEND_DIR = 'backend/the_plug_backend_django'
FRONTEND_DIR = 'frontend/the_plug_svelte_frontend'
CHANGESET_DIR = 'backend/**'
}

triggers {
pollSCM '* * * * *'
}

stages {
stage('SonarQube Analysis') {
when {
changeset "${CHANGESET_DIR}"
}

environment {
SCANNER_HOME = tool 'sonar-scanner-7'
}

steps {
dir("${BACKEND_DIR}") {
withSonarQubeEnv('sonar-backend') {
sh('$SCANNER_HOME/bin/sonar-scanner -Dsonar.projectBaseDir=. -Dsonar.token=$SONAR_TOKEN_BACKEND')
}
}
}
}

stage('Backend Tests') {
when {
changeset "${CHANGESET_DIR}"
}

steps {
dir("${BACKEND_DIR}") {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh '''
python3 -m pip install --upgrade pip --break-system-packages
pip install -r requirements.txt --break-system-packages
python3 manage.py makemigrations api
python3 manage.py test
'''
}
}
}
}

stage('Setup Docker Network') {
when {
changeset "${CHANGESET_DIR}"
}

steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh 'docker network create test'
}
}
}

stage('Run Services') {
when {
changeset "${CHANGESET_DIR}"
}

steps {
dir("${BACKEND_DIR}") {
script {
docker.build('wallys02/the-plug-backend:latest').run(
'--name backend-service --rm --network test --entrypoint ./test-entrypoint.sh ' +
'-e "DB_PASSWORD=$DB_PASSWORD" ' +
'-e "DB_USER=$DB_USER" ' +
'-e "DB_NAME=$DB_NAME" ' +
'-e "DB_HOST=$DB_HOST" ' +
'-e "EMAIL_HOST_PASSWORD=$EMAIL_HOST_PASSWORD" ' +
'-e "EMAIL_HOST_USER=$EMAIL_HOST_USER" ' +
'-e "SECRET_KEY=$SECRET_KEY" ' +
'-e "ALLOWED_HOSTS=$ALLOWED_HOSTS" ' +
'-e "DEBUG=$DEBUG" ' +
'-e "CACHE_ENDPOINT=$CACHE_ENDPOINT" ' +
'-e "CACHE_PASSWORD=$CACHE_PASSWORD" ' +
'-e "USE_CACHE=$USE_CACHE"'
)
}
}

dir("${FRONTEND_DIR}") {
script {
docker.build('wallys02/the-plug-frontend:latest').run('--name frontend --rm --network test')
}
}
}
}

stage('E2E Tests') {
when {
changeset "${CHANGESET_DIR}"
}

agent {
docker {
image 'cypress/included:14.3.3'
args '--name cypress --network test -u root:root -e "CYPRESS_BASE_URL=http://frontend:8080" --entrypoint=""'
}
}

steps {
dir("${FRONTEND_DIR}") {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh '''
npm ci
cypress run --config-file cypress.config.ts --browser chrome --env apiUrl=http://backend-service:8080/api
'''
}
}
}
}

stage('Performance Tests') {
when {
changeset "${CHANGESET_DIR}"
}

agent {
docker {
image 'locustio/locust:latest'
args '--name locust --network test --entrypoint=""'
}
}

steps {
dir("${BACKEND_DIR}") {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh '''
locust -f locustfile.py --headless -u 100 -r 10 -t 3m --host http://backend-service:8080/api
'''
}
}
}
}

stage('DAST Tests') {
when {
changeset "${CHANGESET_DIR}"
}

agent {
docker {
image 'ghcr.io/zaproxy/zaproxy:stable'
args '--name dast --network test'
}
}

steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh '''
zap-full-scan.py -t http://backend-service:8080/api/
'''
}
}
}

stage('Cleanup') {
when {
changeset "${CHANGESET_DIR}"
}

steps {
sh '''
docker stop frontend
docker stop backend-service
'''
}
}

stage('Docker Login & Push') {
when {
changeset "${CHANGESET_DIR}"
}

steps {
script {
docker.withRegistry("${DOCKER_REGISTRY}", 'dockerhub-creds') {
docker.image("${BACKEND_IMAGE}").push()
}
}
}
}

stage('Helm Deployment') {
when {
changeset "${CHANGESET_DIR}"
}

steps {
dir('k8s/helm/the-plug') {
sh '''
chmod +x ./run-helm.sh
./run-helm.sh
kubectl rollout restart deployment/backend --namespace plug-namespace
'''
}
}
}
}

post {
always {
cleanWs()
}
}
}
Empty file removed docker-compose.yml
Empty file.
Loading
Loading