build: Dockerfile + docker-compose with ports driven by .env
- web: nginx:alpine serving the static SPA, listens on WEB_CONTAINER_PORT rendered from deploy/nginx.conf.template (envsubst), gzip + cache headers, /healthz, proxies /api/ to the api container - api: julia:1.13-bookworm, libpq5 + curl, Pkg.instantiate from the committed Manifest, listens on FARM_API_PORT, healthcheck on /api/v1/health - db: postgres:17-alpine with 001_init.sql mounted for first-run schema, pg_isready healthcheck, named volume - every port comes from .env (container port + host port separated); .env.example committed, .env ignored
This commit is contained in:
1 parent
05fd682e33
commit
af19d04496
8 files changed
+297
No files matched your search
@@ -0,0 +1,29 @@
|
||||
# Dockerfile — farm-planning API (Julia + HTTP.jl + LibPQ)
|
||||
# พอร์ตที่ฟังในคอนเทนเนอร์มาจาก env FARM_API_PORT (server.jl อ่านค่านี้เอง)
|
||||
FROM julia:1.13-bookworm
|
||||
|
||||
ENV JULIA_DEPOT_PATH=/opt/julia-depot \
|
||||
JULIA_NUM_THREADS=1 \
|
||||
FARM_API_HOST=0.0.0.0 \
|
||||
FARM_API_PORT=8000 \
|
||||
TZ=Asia/Bangkok
|
||||
|
||||
# libpq = ที่ LibPQ.jl ต้องใช้ · curl = healthcheck
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends libpq5 curl ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /srv
|
||||
|
||||
# ---- ชั้น dependency: เปลี่ยนเฉพาะเมื่อ Project/Manifest เปลี่ยน ----
|
||||
COPY Project.toml Manifest.toml ./
|
||||
RUN julia --project=/srv -e 'using Pkg; Pkg.instantiate(); Pkg.precompile()'
|
||||
|
||||
# ---- ชั้นซอร์ส ----
|
||||
COPY src ./src
|
||||
COPY test ./test
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
# server.jl ฟังที่ FARM_API_HOST:FARM_API_PORT
|
||||
CMD ["julia", "--project=/srv", "/srv/src/server.jl"]
|
||||
Reference in new issue
Block a user