34 lines
940 B
Docker
34 lines
940 B
Docker
FROM ghcr.io/prantlf/vlang:latest AS builder
|
|
WORKDIR ./src/
|
|
|
|
COPY . .
|
|
RUN mkdir -p ./src/../../build/
|
|
|
|
# Build release binary. Output to /src/bin/cdn_app
|
|
# If your main file is main.v in the root of the context, this will work.
|
|
RUN v -prod -o ./src/../../build/ ./main.v
|
|
|
|
# Stage 2: runtime
|
|
FROM debian:bookworm-slim AS runtime
|
|
WORKDIR /app
|
|
|
|
# create non-root user (good practice)
|
|
RUN useradd -m appuser
|
|
|
|
# copy binary from builder
|
|
COPY --from=builder /src/bin/cdn_app /app/cdn_app
|
|
|
|
# copy templates/assets if your binary loads embedded files at runtime or expects files on disk
|
|
# (If you use V's $embed_file at compile time then templates are already embedded and this is optional)
|
|
COPY template/ /app/template/
|
|
COPY util/ /app/util/
|
|
COPY database/ /app/database/
|
|
|
|
RUN chown -R appuser:appuser /app
|
|
USER appuser
|
|
|
|
# expose container ports your app might use (adjust if you use different ports)
|
|
EXPOSE 8080 6767
|
|
|
|
ENTRYPOINT ["/app/cdn_app"]
|