Giter Club home page Giter Club logo

belajar-docker-pemula's Introduction

Belajar Docker untuk Pemula - Membuat TODO App

TODO app ini adalah contoh app untuk mendemokan proses membuat aplikasi dengan Docker, terdiri dari:

Semua komponen dipackage dengan docker

Menjalankan Postgres dengan Docker

Dari Video ke-8

Step 1: Jalankan Postgres

docker run -p 5432:5432 --name todo-postgres -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=rahasia -e POSTGRES_DB=belajar -v $(pwd)/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql -d postgres

Step 2: Export konfigurasi database sebagai environment variabel

export DB_HOST=localhost
export DB_PORT=5432
export DB_USER=postgres
export DB_PASSWORD=rahasia
export DB_DATABASE=belajar

Step 3: Jalankan Backend Golang app di lokal komputer

go run backend/main.go

Step 4: Jalankan Frontend JS app di lokal komputer

cd frontend
yarn install
yarn serve

Step 5: Buka browser untuk mulai mengakses app TODO

http://localhost:8081

Step 6: Cek input TODO tersimpan di database

docker exec -it todo-postgres psql -U postgres -W belajar
SELECT * FROM todo;

Menjalankan Semuanya sebagai Docker Container

Dari Video ke-9 dan ke-10

Step 1: Buat Docker Network

docker network create todo

Step 2: Jalankan Docker postgres di dalam network

docker run -d \
-p 5432:5432 \
--name todo-postgres \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=rahasia \
-e POSTGRES_DB=belajar \
-v $(pwd)/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql \
--network todo \
postgres

Step 3: Buat docker image untuk backend

cd backend
docker build -t todo-backend:v1 .

Step 4: Jalankan backend sebagai docker container di dalam network

docker run -d \
-p 8080:8080 \
--name todo-backend \
-e DB_USER=postgres \
-e DB_PASSWORD=rahasia \
-e DB_HOST=todo-postgres \
-e DB_PORT=5432 \
-e DB_DATABASE=belajar \
--network todo \
todo-backend:v1

Step 5: Buat docker image untuk frontend

cd frontend
docker build -t todo-frontend:v1 .

Step 6: Jalankan frontend sebagai docker container

docker run -d \
-p 8081:8080 \
--name todo-frontend \
--network todo \
todo-frontend:v1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.