Skip to content

Proyek pertama #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: proyek-pertama
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# menggunakan node versi 14 alpine
FROM node:14.21.2-alpine

# Menentukan working directory container adalah /app
WORKDIR /app

# Menyalin seluruh source code ke working directory di container
COPY . .

#Menentukan agar aplikasi berjalan dalam production mode
ENV NODE_ENV=production DB_HOST=item-db

#Menginstal dependencies untuk production & Build
RUN npm install --production --unsafe-perm && npm run build

#Expose port ke 8080
EXPOSE 8080

#run npm start
CMD ["npm","start"]
17 changes: 17 additions & 0 deletions build_push_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# membuat Docker image
docker build -t item-app:v1 .

#melihat daftar image
docker images

#Mengubah nama image
docker tag item-app:v1 ghcr.io/bagus-k/item-app:v1

#save access token Github
export GITHUB_ACCESS_TOKEN="Your Token"

#Login ke GitHub Packages
echo $GITHUB_ACCESS_TOKEN | docker login ghcr.io -u bagusk --password-stdin

#Mengunggah image Github Packages
docker push ghcr.io/bagus-k/item-app:v1
40 changes: 40 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: "3.7"

services:

#service item-db
item-db:

#Menggunakan image mongo:3 dari Docker Hub
image: mongo:3

#Memakai volume bernama app-db dengan target /data/db di container.
volumes:

- app-db:/data/db

ports:
- 27017:27017

#service item-app
item-app:

# Menggunakan image item-app dari GitHub Packages
image: ghcr.io/bagus-k/item-app:v1

container_name: item-app

#port mapping agar dapat diakses dari port 80 di host
ports:

- 80:8080

volumes:

- ./:/app

#restart container
restart: on-failure
volumes:

app-db:
Loading