Proyek: Container Web Statis
Proyek ini mengemas situs katalog produk statis (site/index.html) ke dalam image
nginx:1.29-alpine dan menjalankannya sebagai satu service Compose. Konfigurasi
nginx.conf mengaktifkan gzip, cache 7 hari untuk aset statis, dan no-cache
untuk index.html supaya pembaruan konten langsung terlihat.
Struktur Berkas #
| Berkas | Peran |
|---|---|
site/index.html | Konten situs (katalog produk) |
nginx.conf | Konfigurasi server nginx (gaya conf.d) |
Dockerfile | Resep image multi-layer dengan validasi nginx -t |
.dockerignore | Membatasi build context |
compose.yaml | Definisi service web |
README.md | Dokumen ini |
Menjalankan #
bash
docker compose up -d --buildMenguji #
bash
curl -I http://localhost:8080/
curl -s http://localhost:8080/ | grep "<title>"
curl -I -H "Accept-Encoding: gzip" http://localhost:8080/Hasil yang diharapkan: respons 200 OK dengan header Server: nginx/1.29.4,
Cache-Control: no-cache untuk index.html, Content-Encoding: gzip saat klien
mengirim Accept-Encoding: gzip, dan halaman katalog tampil di browser pada
http://localhost:8080/.
Membersihkan #
bash
docker compose down