forked from dicodingacademy/a433-microservices
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f5aac3
commit 9be79e1
Showing
4 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
PORT=3000 | ||
AMQP_URL="amqp://localhost:5672" | ||
AMQP_URL="amqp://guest:guest@localhost:5672/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# GitHub Actions Workflow | ||
name: Order Service App CI | ||
|
||
# menentukan event yang akan men-trigger workflow | ||
# yaitu setiap ada push baru pada branch `order-service` | ||
on: | ||
push: | ||
branches: | ||
- order-service | ||
|
||
# mendefinisikan job/pekerjaan yang akan dilakukan | ||
jobs: | ||
karsajobs-ci: | ||
name: Test-Build-Push | ||
|
||
# nama environment yang digunakan | ||
environment: order-svc-prod | ||
|
||
# menggunakan Ubuntu versi terbaru untuk menjalankan job | ||
runs-on: ubuntu-latest | ||
|
||
# menyusun urutan tugas | ||
steps: | ||
|
||
# checkout repo agar dapat diakses oleh workflow | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
# menggunakan tools Hadolint untuk memeriksa berkas Dockerfile | ||
- name: Runs Hadolint Dockerfile linting tool | ||
uses: hadolint/hadolint-action@v3.1.0 | ||
with: | ||
dockerfile: "Dockerfile" | ||
|
||
# menjalankan proses build dan push image | ||
- name: Build and Push Docker Image | ||
env: | ||
# personal access token disimpan pada repository secrets GitHub | ||
GHCR_PAT_TOKEN: ${{ secrets.GHCR_PAT_TOKEN }} | ||
run: | | ||
export GHCR_PAT_TOKEN=$GHCR_PAT_TOKEN | ||
bash ./buildpushimage.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# menggunakan base image Node.js versi 20 | ||
FROM node:20 | ||
|
||
# menentukan working directory container pada /app | ||
WORKDIR /app | ||
|
||
# menyalin source code ke working directory di container | ||
COPY . . | ||
|
||
# menginstal dependencies | ||
RUN npm install | ||
|
||
# mengekspos port yang digunakan aplikasi yaitu 3001 | ||
EXPOSE 3000 | ||
|
||
# menjalankan server saat container diluncurkan | ||
CMD ["npm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
|
||
# nama package | ||
package_name="ghcr.io/yogaperdana/order-service:latest" | ||
|
||
# membuat image di Docker dengan format untuk GitHub Container Registry | ||
echo -e "Building a new Docker image:" | ||
docker build . -t $package_name | ||
|
||
# log masuk ke GitHub Container Registry | ||
echo -e "\nLogin into GitHub Container Registry:" | ||
docker login ghcr.io -u yogaperdana -p $GHCR_PAT_TOKEN | ||
|
||
# mengunggah image ke GitHub Container Registry | ||
echo -e "\nPublishing image to GitHub Container Registry:" | ||
docker push $package_name |