graphicek/Dockerfile

58 lines
1.1 KiB
Docker
Raw Normal View History

2022-08-22 09:41:09 +02:00
## 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?_busy_timeout=5000
2022-08-22 09:41:09 +02:00
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"]