Skip to content

Commit f8534d8

Browse files
committed
build: release v2.0.4
1 parent a047f9b commit f8534d8

File tree

7 files changed

+156
-0
lines changed

7 files changed

+156
-0
lines changed

docker/2.0.4/.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
VER_APP=2.0.4
2+
VER_NGX=1.21.6-alpine
3+
VER_GOLANG=1.17.6-alpine3.15
4+
VER_ALPINE=3.15

docker/2.0.4/Dockerfile.base

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM --platform=$BUILDPLATFORM node:20-alpine3.19 AS builder
2+
ENV LANG="en_US.UTF-8"
3+
ENV LANGUAGE="en_US.UTF-8"
4+
ENV LC_ALL="en_US.UTF-8"
5+
RUN apk add --no-cache curl unzip
6+
ARG VER_APP 2.0.4
7+
ENV VER $VER_APP
8+
RUN curl -L "https://github.com/doocs/md/archive/refs/tags/v$VER.zip" -o "v$VER.zip" && unzip "v$VER.zip" && mv "md-$VER" /app
9+
WORKDIR /app
10+
COPY ./patch/vite.config.ts /app/vite.config.ts
11+
ENV NODE_OPTIONS="--openssl-legacy-provider"
12+
RUN npm i && npm run build
13+
14+
FROM scratch
15+
LABEL MAINTAINER="ylb<[email protected]>"
16+
COPY --from=builder /app/dist /app/assets

docker/2.0.4/Dockerfile.nginx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ARG VER_APP=2.0.4
2+
ARG VER_NGX="1.21.6-alpine"
3+
4+
FROM --platform=$BUILDPLATFORM doocs/md:$VER_APP-assets AS assets
5+
FROM --platform=$TARGETPLATFORM nginx:${VER_NGX}
6+
LABEL MAINTAINER="ylb<[email protected]>"
7+
COPY --from=assets /app/assets /usr/share/nginx/html

docker/2.0.4/Dockerfile.standalone

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
ARG VER_APP=2.0.4
2+
ARG VER_GOLANG=1.17.6-alpine3.15
3+
ARG VER_ALPINE=3.15
4+
5+
FROM --platform=$BUILDPLATFORM "doocs/md:$VER_APP-assets" AS assets
6+
7+
FROM --platform=$BUILDPLATFORM "golang:$VER_GOLANG" AS gobuilder
8+
ARG TARGETARCH
9+
ARG TARGETOS
10+
COPY --from=assets /app/* /app/assets/
11+
COPY server/main.go /app
12+
RUN apk add git bash gcc musl-dev upx
13+
WORKDIR /app
14+
ENV GOOS=$TARGETOS GOARCH=$TARGETARCH
15+
RUN go build -ldflags "-w -s" -o md main.go && \
16+
apk add upx && \
17+
if [ "$TARGETARCH" = "amd64" ]; then upx -9 -o md.minify md; else cp md md.minify; fi
18+
19+
FROM --platform=$TARGETPLATFORM "alpine:$VER_ALPINE"
20+
LABEL MAINTAINER="ylb<[email protected]>"
21+
COPY --from=gobuilder /app/md.minify /bin/md
22+
EXPOSE 80
23+
CMD ["md"]

docker/2.0.4/Dockerfile.static

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ARG VER_APP=2.0.4
2+
FROM --platform=$BUILDPLATFORM "doocs/md:$VER_APP-assets" AS assets
3+
4+
# detail https://github.com/lipanski/docker-static-website/blob/master/Dockerfile
5+
FROM --platform=$TARGETPLATFORM lipanski/docker-static-website
6+
7+
WORKDIR /home/static
8+
9+
COPY --from=assets /app/assets /home/static
10+
11+
EXPOSE 80
12+
13+
CMD ["/busybox-httpd", "-f", "-v", "-p", "80", "-c", "httpd.conf"]

docker/2.0.4/patch/vite.config.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import path from 'node:path'
2+
import process from 'node:process'
3+
4+
import vue from '@vitejs/plugin-vue'
5+
import { visualizer } from 'rollup-plugin-visualizer'
6+
import UnoCSS from 'unocss/vite'
7+
import AutoImport from 'unplugin-auto-import/vite'
8+
import Components from 'unplugin-vue-components/vite'
9+
import { defineConfig } from 'vite'
10+
import { nodePolyfills } from 'vite-plugin-node-polyfills'
11+
import { VitePluginRadar } from 'vite-plugin-radar'
12+
import vueDevTools from 'vite-plugin-vue-devtools'
13+
14+
export default defineConfig({
15+
base: `/`,
16+
define: { process },
17+
envPrefix: [`VITE_`, `CF_`],
18+
plugins: [
19+
vue(),
20+
UnoCSS(),
21+
vueDevTools(),
22+
nodePolyfills({
23+
include: [`path`, `util`, `timers`, `stream`, `fs`],
24+
overrides: {
25+
// Since `fs` is not supported in browsers, we can use the `memfs` package to polyfill it.
26+
// fs: 'memfs',
27+
},
28+
}),
29+
VitePluginRadar({
30+
analytics: { id: `G-7NZL3PZ0NK` },
31+
}),
32+
process.env.ANALYZE === `true`
33+
&& visualizer({ emitFile: true, filename: `stats.html` }),
34+
AutoImport({
35+
imports: [`vue`, `pinia`, `@vueuse/core`],
36+
dirs: [`./src/stores`, `./src/utils/toast`],
37+
}),
38+
Components({
39+
resolvers: [],
40+
}),
41+
],
42+
resolve: {
43+
alias: { '@': path.resolve(__dirname, `./src`) },
44+
},
45+
css: { devSourcemap: true },
46+
build: {
47+
rollupOptions: {
48+
output: {
49+
chunkFileNames: `static/js/md-[name]-[hash].js`,
50+
entryFileNames: `static/js/md-[name]-[hash].js`,
51+
assetFileNames: `static/[ext]/md-[name]-[hash].[ext]`,
52+
manualChunks(id) {
53+
if (id.includes(`node_modules`)) {
54+
if (id.includes(`katex`))
55+
return `katex`
56+
if (id.includes(`mermaid`))
57+
return `mermaid`
58+
if (id.includes(`cytoscape`))
59+
return `cytoscape`
60+
if (id.includes(`highlight.js`))
61+
return `hljs`
62+
const pkg = id
63+
.split(`node_modules/`)[1]
64+
.split(`/`)[0]
65+
.replace(`@`, `npm_`)
66+
return `vendor_${pkg}`
67+
}
68+
},
69+
},
70+
},
71+
},
72+
})

docker/2.0.4/server/main.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package main
2+
3+
import (
4+
"embed"
5+
"io/fs"
6+
"log"
7+
"net/http"
8+
)
9+
10+
//go:embed assets
11+
var assets embed.FS
12+
13+
func main() {
14+
mutex := http.NewServeMux()
15+
md, _ := fs.Sub(assets, "assets")
16+
mutex.Handle("/", http.FileServer(http.FS(md)))
17+
err := http.ListenAndServe(":80", mutex)
18+
if err != nil {
19+
log.Fatal(err)
20+
}
21+
}

0 commit comments

Comments
 (0)