feat(controller): intial build functions setup in go and service building

This commit is contained in:
2025-09-05 09:14:34 -05:00
parent 8a07c8afe4
commit 87aafef350
13 changed files with 510 additions and 8 deletions

71
controller/Dockerfile Normal file
View File

@@ -0,0 +1,71 @@
# # ---- Builder Stage ----
# FROM golang:1.24.4-alpine3.22 AS builder
# WORKDIR /app/controller
# # Copy Go module manifests
# COPY controller/go.mod controller/go.sum ./
# RUN go mod download
# # Copy the controller source code
# COPY controller/ ./
# # Build the binary
# RUN CGO_ENABLED=0 GOOS=linux go build -o /app/lst_ctl .
# # ---- Runtime Stage ----
# FROM alpine:latest
# WORKDIR /root/
# # Copy only the binary (no need for sources)
# COPY --from=builder /app/lst_ctl .
# # (Optional) Persist data output if controller writes files
# RUN mkdir -p /data
# VOLUME /data
# # Expose Gin API port
# EXPOSE 8080
# ENV RUNNING_IN_DOCKER=true
# CMD ["./lst_ctl"]
# ---- Build Go binary ----
FROM golang:1.24.4-alpine3.22 AS gobuilder
WORKDIR /src
# copy controller module
COPY controller/go.mod controller/go.sum ./
RUN go mod download
# copy all controller source code
COPY controller/ ./
# build binary into /bin
RUN CGO_ENABLED=0 GOOS=linux go build -o /bin/lst_ctl .
# ---- Runtime with Node ----
FROM node:20-alpine
WORKDIR /app
# copy binary from builder
COPY --from=gobuilder /bin/lst_ctl /usr/local/bin/lst_ctl
# copy repo root into /app (npm needs package.json, dist/, frontend/, etc)
COPY . .
# clear Node's default entrypoint (Docker Hub node images use ["docker-entrypoint.sh"])
ENTRYPOINT []
# expose gin api
EXPOSE 8080
ENV RUNNING_IN_DOCKER=true
# run binary (in PATH now, since it's under /usr/local/bin)
CMD ["lst_ctl"]