-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (41 loc) · 1.2 KB
/
Dockerfile
File metadata and controls
57 lines (41 loc) · 1.2 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
# syntax=docker/dockerfile:1.4
########################
# 1️⃣ Build Stage
########################
FROM node:22 AS build
WORKDIR /app
# Build arguments
ARG VITE_APP_API_URL
ARG VITE_APP_APP_URL
# Expose them as env for build process
ENV VITE_APP_API_URL=$VITE_APP_API_URL
ENV VITE_APP_APP_URL=$VITE_APP_APP_URL
# Copy only dependency files
COPY package.json yarn.lock ./
# Install dependencies
RUN yarn install --frozen-lockfile
# Copy source
COPY . .
# Build static files
RUN yarn build
########################
# 2️⃣ Production Stage
########################
FROM nginx:alpine
# Remove default nginx content
RUN rm -rf /usr/share/nginx/html/*
# Copy custom nginx config
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
# Copy built React app
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
ENTRYPOINT ["nginx", "-g", "daemon off;"]
# docker build \
# --build-arg VITE_APP_API_URL=https://realworldapi.minhhoccode111.com \
# --build-arg VITE_APP_APP_URL=https://realworld.minhhoccode111.com \
# -t minhhoccode111/realworld-react:latest .
# docker run -d \
# --name realworld-react \
# --restart unless-stopped \
# -p 127.0.0.1:3000:80 \
# minhhoccode111/realworld-react:latest