forked from excalidraw/excalidraw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
77 lines (65 loc) · 1.97 KB
/
Dockerfile
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
FROM node:18
WORKDIR /app
# Copy the entire repository content
COPY . .
# Install global dependencies with specific versions
RUN npm install -g [email protected] [email protected] --force
# Clean yarn cache and install dependencies with specific resolutions
RUN yarn cache clean
RUN echo '{\n\
"resolutions": {\n\
"@babel/core": "^7.0.0",\n\
"strip-ansi": "^6.0.1",\n\
"typescript": "^5.0.2",\n\
"react": "^18.2.0"\n\
}\n\
}' > .yarnrc.json
# Install workspace dependencies
RUN yarn install --frozen-lockfile --network-timeout 300000
# Set build environment variables
ENV VITE_APP_ENABLE_TRACKING=true
ENV VITE_APP_GIT_SHA=development
ENV NODE_ENV=production
ENV VITE_APP_DOCKER_BUILD=true
# Move to app directory
WORKDIR /app/excalidraw-app
# Create a simplified vite config for Docker build
RUN echo 'import { defineConfig } from "vite";\n\
import react from "@vitejs/plugin-react";\n\
import { VitePWA } from "vite-plugin-pwa";\n\
import svgrPlugin from "vite-plugin-svgr";\n\
import { ViteEjsPlugin } from "vite-plugin-ejs";\n\
import { createHtmlPlugin } from "vite-plugin-html";\n\
\n\
export default defineConfig({\n\
build: {\n\
outDir: "build",\n\
sourcemap: true,\n\
assetsInlineLimit: 0\n\
},\n\
plugins: [\n\
react(),\n\
svgrPlugin(),\n\
ViteEjsPlugin(),\n\
VitePWA({ registerType: "autoUpdate" }),\n\
createHtmlPlugin({ minify: true })\n\
],\n\
define: {\n\
"process.env.IS_PREACT": JSON.stringify("false")\n\
}\n\
});' > vite.config.docker.mts
# Install required dependencies
RUN yarn add -D @vitejs/[email protected] \
# Build the app using the Docker config
RUN cross-env VITE_APP_DISABLE_SENTRY=true vite build --config vite.config.docker.mts
# Serve the built files
RUN npm install -g serve
CMD ["serve", "-s", "build", "-p", "3000"]
EXPOSE 3000