Skip to content

Commit 2958d22

Browse files
committed
feat: add docker images for 2.0.1 and 2.0.2
1 parent cc6a847 commit 2958d22

File tree

15 files changed

+318
-0
lines changed

15 files changed

+318
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
├── docker 镜像文件目录(包含最新分支和 1.6.0 之后的版本)
1111
│   ├── 1.6.0
1212
│   ├── 2.0.0
13+
│   ├── 2.0.1
14+
│   ├── 2.0.2
1315
│   └── latest
1416
└── scripts 构建镜像使用的脚本
1517
├── build-base-image.sh 构建基础镜像
@@ -26,6 +28,8 @@
2628

2729
```bash
2830
docker run --rm -it -p 8080:80 doocs/md:latest
31+
docker run --rm -it -p 8080:80 doocs/md:2.0.2
32+
docker run --rm -it -p 8080:80 doocs/md:2.0.1
2933
docker run --rm -it -p 8080:80 doocs/md:2.0.0
3034
docker run --rm -it -p 8080:80 doocs/md:1.6.0
3135
```
@@ -36,6 +40,8 @@ docker run --rm -it -p 8080:80 doocs/md:1.6.0
3640

3741
```bash
3842
docker run --rm -it -p 8080:80 doocs/md:latest-nginx
43+
docker run --rm -it -p 8080:80 doocs/md:2.0.2-nginx
44+
docker run --rm -it -p 8080:80 doocs/md:2.0.1-nginx
3945
docker run --rm -it -p 8080:80 doocs/md:2.0.0-nginx
4046
docker run --rm -it -p 8080:80 doocs/md:1.6.0-nginx
4147
```

docker/2.0.1/.env

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

docker/2.0.1/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.1
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.1/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.1
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 /usr/share/nginx/html

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

docker/2.0.1/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+
}

docker/2.0.2/.env

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

docker/2.0.2/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.2
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

0 commit comments

Comments
 (0)