Working docker build
This commit is contained in:
parent
4e5cb734b6
commit
3f9e3ecee5
|
|
@ -0,0 +1,57 @@
|
||||||
|
## Build server
|
||||||
|
FROM golang:1.19-buster AS build
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY server/go.mod ./
|
||||||
|
COPY server/go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
COPY server/*.go ./
|
||||||
|
COPY server/app/*.go ./app/
|
||||||
|
COPY server/config/*.go ./config/
|
||||||
|
COPY server/routes/*.go ./routes/
|
||||||
|
COPY server/services/*.go ./services/
|
||||||
|
COPY server/middleware/*.go ./middleware/
|
||||||
|
|
||||||
|
RUN go build -o /basic-sensor-receiver
|
||||||
|
RUN mkdir /data
|
||||||
|
|
||||||
|
## Build client
|
||||||
|
FROM node:alpine AS build-client
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY client/package.json ./
|
||||||
|
COPY client/package-lock.json ./
|
||||||
|
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
COPY client/tsconfig.json ./
|
||||||
|
COPY client/vite.config.js ./
|
||||||
|
COPY client/src ./src
|
||||||
|
COPY client/index.html ./
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
## Deploy
|
||||||
|
FROM gcr.io/distroless/base-debian10
|
||||||
|
|
||||||
|
WORKDIR /
|
||||||
|
|
||||||
|
COPY --from=build /basic-sensor-receiver /basic-sensor-receiver
|
||||||
|
COPY --from=build /data /data
|
||||||
|
COPY --from=build-client /app/dist /client
|
||||||
|
|
||||||
|
ENV PORT 80
|
||||||
|
ENV GIN_MODE release
|
||||||
|
ENV DATABASE_URL /data/sensors.sqlite3
|
||||||
|
ENV BIND_IP 0.0.0.0
|
||||||
|
ENV AUTH_USERNAME admin
|
||||||
|
ENV AUTH_PASSWORD password
|
||||||
|
ENV AUTH_KEY password
|
||||||
|
|
||||||
|
EXPOSE ${PORT}
|
||||||
|
VOLUME [ "/data" ]
|
||||||
|
|
||||||
|
ENTRYPOINT ["/basic-sensor-receiver"]
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
## Build
|
|
||||||
FROM golang:1.19-buster AS build
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY go.mod ./
|
|
||||||
COPY go.sum ./
|
|
||||||
RUN go mod download
|
|
||||||
|
|
||||||
COPY *.go ./
|
|
||||||
COPY app/*.go ./app/
|
|
||||||
COPY config/*.go ./config/
|
|
||||||
COPY routes/*.go ./routes/
|
|
||||||
COPY services/*.go ./services/
|
|
||||||
|
|
||||||
RUN go build -o /basic-sensor-receiver
|
|
||||||
RUN mkdir /data
|
|
||||||
|
|
||||||
## Deploy
|
|
||||||
FROM gcr.io/distroless/base-debian10
|
|
||||||
|
|
||||||
WORKDIR /
|
|
||||||
|
|
||||||
COPY --from=build /basic-sensor-receiver /basic-sensor-receiver
|
|
||||||
COPY --from=build /data /data
|
|
||||||
COPY client ./client
|
|
||||||
|
|
||||||
ENV PORT 80
|
|
||||||
ENV GIN_MODE release
|
|
||||||
ENV DATABASE_URL /data/sensors.sqlite3
|
|
||||||
ENV BIND_IP 0.0.0.0
|
|
||||||
ENV AUTH_USERNAME admin
|
|
||||||
ENV AUTH_PASSWORD password
|
|
||||||
|
|
||||||
EXPOSE ${PORT}
|
|
||||||
VOLUME [ "/data" ]
|
|
||||||
|
|
||||||
ENTRYPOINT ["/basic-sensor-receiver"]
|
|
||||||
Loading…
Reference in New Issue