Skip to content

Commit 7ae1196

Browse files
committed
build: release v2.0.3
1 parent 1022aec commit 7ae1196

File tree

8 files changed

+160
-0
lines changed

8 files changed

+160
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
│   ├── 2.0.0
1313
│   ├── 2.0.1
1414
│   ├── 2.0.2
15+
│   ├── 2.0.3
1516
│   └── latest
1617
└── scripts 构建镜像使用的脚本
1718
├── build-base-image.sh 构建基础镜像
@@ -28,6 +29,7 @@
2829

2930
```bash
3031
docker run --rm -it -p 8080:80 doocs/md:latest
32+
docker run --rm -it -p 8080:80 doocs/md:2.0.3
3133
docker run --rm -it -p 8080:80 doocs/md:2.0.2
3234
docker run --rm -it -p 8080:80 doocs/md:2.0.1
3335
docker run --rm -it -p 8080:80 doocs/md:2.0.0
@@ -40,6 +42,7 @@ docker run --rm -it -p 8080:80 doocs/md:1.6.0
4042

4143
```bash
4244
docker run --rm -it -p 8080:80 doocs/md:latest-nginx
45+
docker run --rm -it -p 8080:80 doocs/md:2.0.3-nginx
4346
docker run --rm -it -p 8080:80 doocs/md:2.0.2-nginx
4447
docker run --rm -it -p 8080:80 doocs/md:2.0.1-nginx
4548
docker run --rm -it -p 8080:80 doocs/md:2.0.0-nginx

docker/2.0.3/.env

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

docker/2.0.3/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.3
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<contact@yanglibin.info>"
16+
COPY --from=builder /app/dist /app/assets

docker/2.0.3/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.3
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<contact@yanglibin.info>"
7+
COPY --from=assets /app /usr/share/nginx/html

docker/2.0.3/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.3
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<contact@yanglibin.info>"
21+
COPY --from=gobuilder /app/md.minify /bin/md
22+
EXPOSE 80
23+
CMD ["md"]

docker/2.0.3/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.3
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 /home/static
10+
11+
EXPOSE 80
12+
13+
CMD ["/busybox-httpd", "-f", "-v", "-p", "80", "-c", "httpd.conf"]

docker/2.0.3/patch/vite.config.ts

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
// https://vitejs.dev/config/
15+
export default defineConfig({
16+
base: `/`, // 基本路径, 建议以绝对路径跟随访问目录
17+
define: {
18+
process,
19+
},
20+
envPrefix: [`VITE_`, `CF_`], // 允许 VITE_ 和 CF_ 前缀的变量
21+
plugins: [
22+
vue(),
23+
UnoCSS(),
24+
vueDevTools(),
25+
nodePolyfills({
26+
include: [`path`, `util`, `timers`, `stream`, `fs`],
27+
overrides: {
28+
// Since `fs` is not supported in browsers, we can use the `memfs` package to polyfill it.
29+
// fs: 'memfs',
30+
},
31+
}),
32+
VitePluginRadar({
33+
analytics: {
34+
id: `G-7NZL3PZ0NK`,
35+
},
36+
}),
37+
process.env.ANALYZE === `true` && visualizer({
38+
emitFile: true,
39+
filename: `stats.html`,
40+
}),
41+
AutoImport({
42+
imports: [
43+
`vue`,
44+
`pinia`,
45+
`@vueuse/core`,
46+
],
47+
dirs: [
48+
`./src/stores`,
49+
`./src/utils/toast`,
50+
],
51+
}),
52+
Components({
53+
resolvers: [],
54+
}),
55+
],
56+
resolve: {
57+
alias: {
58+
'@': path.resolve(__dirname, `./src`),
59+
},
60+
},
61+
css: {
62+
devSourcemap: true,
63+
},
64+
build: {
65+
rollupOptions: {
66+
output: {
67+
chunkFileNames: `static/js/md-[name]-[hash].js`,
68+
entryFileNames: `static/js/md-[name]-[hash].js`,
69+
assetFileNames: `static/[ext]/md-[name]-[hash].[ext]`,
70+
},
71+
},
72+
},
73+
})

docker/2.0.3/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)