diff --git a/dockerbuild.sh b/dockerbuild.sh new file mode 100644 index 0000000..69e5354 --- /dev/null +++ b/dockerbuild.sh @@ -0,0 +1,3 @@ +# Nginx version build script +# Run Example: docker run --rm -p 8282:8282 buitar/buitar +docker build -t buitar/buitar:latest -f dockerfile/Dockerfile . \ No newline at end of file diff --git a/dockerfile/Dockerfile b/dockerfile/Dockerfile new file mode 100644 index 0000000..9e4317e --- /dev/null +++ b/dockerfile/Dockerfile @@ -0,0 +1,26 @@ +# stage-1: build +FROM node:alpine as builder + +RUN npm install -g pnpm + +WORKDIR /app + +COPY . . + +RUN pnpm install --no-frozen-lockfile && \ + pnpm build + +# stage-2: package-static +FROM nginx:alpine + +COPY --from=builder /app/packages/buitar/dist /usr/share/nginx/html/buitar +COPY --from=builder /app/packages/buitar-editor/dist /usr/share/nginx/html/buitar-editor +COPY --from=builder /app/packages/svg-chord/dist /usr/share/nginx/html/svg-chord +COPY --from=builder /app/packages/to-guitar/dist /usr/share/nginx/html/to-guitar +COPY --from=builder /app/packages/tone-player/dist /usr/share/nginx/html/tone-player + +COPY dockerfile/nginx.conf /etc/nginx/nginx.conf + +EXPOSE 8282 8283 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/dockerfile/nginx.conf b/dockerfile/nginx.conf new file mode 100644 index 0000000..b60405c --- /dev/null +++ b/dockerfile/nginx.conf @@ -0,0 +1,32 @@ +worker_processes auto; +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + + + server { + listen 8282; + server_name localhost; + + location / { + root /app/packages/buitar/dist/; + index index.html; + } + } + + server { + listen 8283; + server_name localhost; + + location / { + root /app/packages/buitar-editor/dist/; + index index.html; + } + } +} diff --git a/packages/buitar-editor/vite.config.ts b/packages/buitar-editor/vite.config.ts index 9511881..b647100 100644 --- a/packages/buitar-editor/vite.config.ts +++ b/packages/buitar-editor/vite.config.ts @@ -19,6 +19,6 @@ export default defineConfig({ server: { port: 8283, host: '0.0.0.0', - open: '/', + open: false, } }) diff --git a/packages/buitar/vite.config.ts b/packages/buitar/vite.config.ts index 50db522..c973d30 100644 --- a/packages/buitar/vite.config.ts +++ b/packages/buitar/vite.config.ts @@ -123,7 +123,7 @@ export default defineConfig({ server: { port: 8282, host: '0.0.0.0', - open: '/', + open: false, }, optimizeDeps: { include: ['react', 'react-dom'],