diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..6e0db6b44 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,57 @@ +pipeline { + agent { label 'server1-ryan' } + + stages { + stage('Pull SCM') { + steps { + git branch: 'main', url: 'https://github.com/ryanfitra/simple-apps.git' + } + } + + stage('Build') { + steps { + sh''' + cd app + npm install + ''' + } + } + + stage('Testing') { + steps { + sh''' + cd app + APP_PORT=5001 npm test + APP_PORT=5001 npm run test:coverage + ''' + } + } + + // stage('Code Review') { + // steps { + // sh''' + // cd app + // sonar-scanner \ + // -Dsonar.projectKey=Simple-Apps \ + // -Dsonar.sources=. \ + // -Dsonar.host.url=http://172.23.x.x:9000 \ + // -Dsonar.login=token-sonar + // ''' + // } + // } + + stage('Deploy') { + steps { + sh''' + docker compose up --build -d + ''' + } + } + + stage('Backup') { + steps { + sh 'docker compose push' + } + } + } +} \ No newline at end of file diff --git a/app/Dockerfile b/app/Dockerfile new file mode 100644 index 000000000..6baccdd18 --- /dev/null +++ b/app/Dockerfile @@ -0,0 +1,7 @@ +FROM node:20-slim +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +EXPOSE 3000 +CMD ["npm", "start"] \ No newline at end of file diff --git a/README.md b/app/README.md similarity index 100% rename from README.md rename to app/README.md diff --git a/app.js b/app/app.js similarity index 100% rename from app.js rename to app/app.js diff --git a/database/training.sql b/app/database/training.sql similarity index 100% rename from database/training.sql rename to app/database/training.sql diff --git a/middleware/db_connect.js b/app/middleware/db_connect.js similarity index 100% rename from middleware/db_connect.js rename to app/middleware/db_connect.js diff --git a/middleware/logger.js b/app/middleware/logger.js similarity index 100% rename from middleware/logger.js rename to app/middleware/logger.js diff --git a/package.json b/app/package.json similarity index 90% rename from package.json rename to app/package.json index 098f48be3..6de9fa897 100644 --- a/package.json +++ b/app/package.json @@ -7,7 +7,7 @@ "dev": "nodemon app", "start": "node app", "test": "jest --forceExit testing/", - "test:coverage": "jest --coverage testing/" + "test:coverage": "jest --coverage --forceExit testing/" }, "author": "Moch Rafi Riadi", "license": "ISC", diff --git a/public/images/idn-logo.png b/app/public/images/idn-logo.png similarity index 100% rename from public/images/idn-logo.png rename to app/public/images/idn-logo.png diff --git a/app/public/index.html b/app/public/index.html new file mode 100644 index 000000000..c0922c1a4 --- /dev/null +++ b/app/public/index.html @@ -0,0 +1,90 @@ + + + + + + Training DevOps + + + + + +
+ + +

Belajar DevOps

+

Rian Fitra Perdana

+

Training DevOps IDN

+ +
+ 🚀 Check Point: Docker Compose +
+
+ 🚀 Check Point: Jenkins 1 +
+ + +
+ + diff --git a/public/stylesheet/style.css b/app/public/stylesheet/style.css similarity index 100% rename from public/stylesheet/style.css rename to app/public/stylesheet/style.css diff --git a/testing/app.test.js b/app/testing/app.test.js similarity index 100% rename from testing/app.test.js rename to app/testing/app.test.js diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 000000000..522651b7c --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,13 @@ +name: simple-apps + +services: + app: + image: ryanfitra19/simple-app + build: ./app + ports: + - "5000:3000" + volumes: + - vol-simple:/app/public/images/ + +volumes: + vol-simple: \ No newline at end of file diff --git a/public/index.html b/public/index.html deleted file mode 100644 index d6785c439..000000000 --- a/public/index.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - Training DevOps - - - - -

Belajar Devops

- - \ No newline at end of file