-
-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (43 loc) · 1.65 KB
/
Dockerfile
File metadata and controls
59 lines (43 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Build stage
FROM node:20-alpine AS build
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy source code
COPY . .
ARG VITE_MYFIN_BASE_API_URL
ENV VITE_MYFIN_BASE_API_URL="myfin-api-url-placeholder"
# Build the app
RUN npm run build
# Serve stage
FROM nginx:alpine
WORKDIR /usr/share/nginx/html
ARG VERSION="9.4.0"
# Add metadata
LABEL maintainer="José Valdiviesso <me@zmiguel.me>"
LABEL author="José Valdiviesso <me@zmiguel.me>"
LABEL version="${VERSION}"
LABEL description="MyFin Frontend Application"
LABEL org.opencontainers.image.authors="José Valdiviesso <me@zmiguel.me>"
LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.title="MyFin Frontend"
LABEL org.opencontainers.image.description="Web frontend for the personal finances platform that'll help you budget, keep track of your income/spending and forecast your financial future."
LABEL org.opencontainers.image.source="https://github.com/afaneca/myfin"
# Copy built files from build stage
COPY --from=build /app/dist /usr/share/nginx/html
# Copy nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Create startup script
RUN echo '#!/bin/sh' > /start.sh && \
echo 'find /usr/share/nginx/html -type f -name "*.js" -exec sed -i "s|myfin-api-url-placeholder|$VITE_MYFIN_BASE_API_URL|g" {} +' >> /start.sh && \
echo "nginx -g 'daemon off;'" >> /start.sh && \
chmod +x /start.sh
# Expose port 80
EXPOSE 80
# Healthcheck
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -qO- http://localhost:80/ | grep -q '<title>MyFin Budget</title>' || exit 1
# Start nginx
CMD ["/start.sh"]