focus/Dockerfile

42 lines
688 B
Docker
Raw Permalink Normal View History

2024-01-26 16:16:48 +01:00
#Frontend
2024-01-10 00:39:55 +01:00
FROM node:20 as frontend-builder
2024-01-26 16:16:48 +01:00
2024-01-10 00:39:55 +01:00
WORKDIR /app
2024-01-26 16:16:48 +01:00
COPY frontend/package.json .
COPY frontend/package-lock.json .
2024-01-10 00:39:55 +01:00
RUN npm install
2024-01-26 16:16:48 +01:00
COPY frontend .
2024-01-10 00:39:55 +01:00
RUN npm run build
2024-01-26 16:16:48 +01:00
# Backend
2024-01-10 00:39:55 +01:00
FROM golang:1.21.5 as backend-builder
WORKDIR /app
COPY backend/. .
RUN CGO_ENABLED=1 GOOS=linux go build -o main
2024-01-26 16:16:48 +01:00
# Combined
2024-01-10 00:39:55 +01:00
FROM debian:stable-slim
WORKDIR /app
2024-01-26 16:16:48 +01:00
RUN apt-get update && \
apt-get install -y nginx
COPY --from=frontend-builder /app/build /var/www/html
2024-01-10 00:39:55 +01:00
COPY --from=backend-builder /app/main /app/backend/main
2024-01-26 16:16:48 +01:00
COPY run.sh /app/run.sh
RUN chmod +x /app/run.sh
2024-01-10 00:39:55 +01:00
VOLUME /data
2024-01-26 16:16:48 +01:00
EXPOSE 80 3000
2024-01-10 00:39:55 +01:00
ENV DB_PATH=/data/db.sqlite
ENV PUBLIC_BACKEND_URL=http://localhost:3000
CMD ["/app/run.sh"]