-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile.cms
149 lines (143 loc) · 7.02 KB
/
Dockerfile.cms
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
## Dockerfile to package DO CMS runtime.
# Sample build command:
# docker build --rm -t docms:0.1.0 -f Dockerfile.cms .
FROM node:18-alpine AS builder_fe_bootstrap
RUN mkdir /build
RUN apk add jq sed
COPY . /build
RUN cd /build \
&& export APP_NAME=`jq -r '.name' appinfo.json` \
&& export APP_SHORTNAME=`jq -r '.shortname' appinfo.json` \
&& export APP_INITIAL=`jq -r '.initial' appinfo.json` \
&& export APP_VERSION=`jq -r '.version' appinfo.json` \
&& export APP_DESC=`jq -r '.description' appinfo.json` \
&& echo "Building fe-bootstrap..." \
&& cd /build/fe \
&& rm -rf .env \
&& rm -rf dist node_modules \
&& sed -i s/#{pageTitle}/"$APP_NAME v$APP_VERSION"/g public/index.html \
&& sed -i s/#{appName}/"$APP_NAME"/g public/index.html \
&& sed -i s/#{appInitial}/"$APP_INITIAL"/g public/index.html \
&& sed -i s/#{appShortname}/"$APP_SHORTNAME"/g public/index.html \
&& sed -i s/#{appDescription}/"$APP_DESC"/g public/index.html \
&& sed -i s/#{appVersion}/"$APP_VERSION"/g public/index.html \
&& sed -i s/#{appName}/"$APP_NAME"/g src/_shared/config.json \
&& sed -i s/#{appInitial}/"$APP_INITIAL"/g src/_shared/config.json \
&& sed -i s/#{appShortname}/"$APP_SHORTNAME"/g src/_shared/config.json \
&& sed -i s/#{appDescription}/"$APP_DESC"/g src/_shared/config.json \
&& sed -i s/#{appVersion}/"$APP_VERSION"/g src/_shared/config.json \
&& npm install && npm run build:bootstrap
FROM node:18-alpine AS builder_fe_coderdocs
RUN mkdir /build
RUN apk add jq sed
COPY . /build
RUN cd /build \
&& export APP_NAME=`jq -r '.name' appinfo.json` \
&& export APP_SHORTNAME=`jq -r '.shortname' appinfo.json` \
&& export APP_INITIAL=`jq -r '.initial' appinfo.json` \
&& export APP_VERSION=`jq -r '.version' appinfo.json` \
&& export APP_DESC=`jq -r '.description' appinfo.json` \
&& echo "Building fe-coderdocs..." \
&& cd /build/fe \
&& rm -rf .env \
&& rm -rf dist node_modules \
&& sed -i s/#{pageTitle}/"$APP_NAME v$APP_VERSION"/g public/index.html \
&& sed -i s/#{appName}/"$APP_NAME"/g public/index.html \
&& sed -i s/#{appInitial}/"$APP_INITIAL"/g public/index.html \
&& sed -i s/#{appShortname}/"$APP_SHORTNAME"/g public/index.html \
&& sed -i s/#{appDescription}/"$APP_DESC"/g public/index.html \
&& sed -i s/#{appVersion}/"$APP_VERSION"/g public/index.html \
&& sed -i s/#{appName}/"$APP_NAME"/g src/_shared/config.json \
&& sed -i s/#{appInitial}/"$APP_INITIAL"/g src/_shared/config.json \
&& sed -i s/#{appShortname}/"$APP_SHORTNAME"/g src/_shared/config.json \
&& sed -i s/#{appDescription}/"$APP_DESC"/g src/_shared/config.json \
&& sed -i s/#{appVersion}/"$APP_VERSION"/g src/_shared/config.json \
&& npm install && npm run build:coderdocs
FROM node:18-alpine AS builder_fe_prettydocs
RUN mkdir /build
RUN apk add jq sed
COPY . /build
RUN cd /build \
&& export APP_NAME=`jq -r '.name' appinfo.json` \
&& export APP_SHORTNAME=`jq -r '.shortname' appinfo.json` \
&& export APP_INITIAL=`jq -r '.initial' appinfo.json` \
&& export APP_VERSION=`jq -r '.version' appinfo.json` \
&& export APP_DESC=`jq -r '.description' appinfo.json` \
&& echo "Building fe-prettydocs..." \
&& cd /build/fe \
&& rm -rf .env \
&& rm -rf dist node_modules \
&& sed -i s/#{pageTitle}/"$APP_NAME v$APP_VERSION"/g public/index.html \
&& sed -i s/#{appName}/"$APP_NAME"/g public/index.html \
&& sed -i s/#{appInitial}/"$APP_INITIAL"/g public/index.html \
&& sed -i s/#{appShortname}/"$APP_SHORTNAME"/g public/index.html \
&& sed -i s/#{appDescription}/"$APP_DESC"/g public/index.html \
&& sed -i s/#{appVersion}/"$APP_VERSION"/g public/index.html \
&& sed -i s/#{appName}/"$APP_NAME"/g src/_shared/config.json \
&& sed -i s/#{appInitial}/"$APP_INITIAL"/g src/_shared/config.json \
&& sed -i s/#{appShortname}/"$APP_SHORTNAME"/g src/_shared/config.json \
&& sed -i s/#{appDescription}/"$APP_DESC"/g src/_shared/config.json \
&& sed -i s/#{appVersion}/"$APP_VERSION"/g src/_shared/config.json \
&& npm install && npm run build:prettydocs
FROM node:18-alpine AS builder_fe_blogy
RUN mkdir /build
RUN apk add jq sed
COPY . /build
RUN cd /build \
&& export APP_NAME=`jq -r '.name' appinfo.json` \
&& export APP_SHORTNAME=`jq -r '.shortname' appinfo.json` \
&& export APP_INITIAL=`jq -r '.initial' appinfo.json` \
&& export APP_VERSION=`jq -r '.version' appinfo.json` \
&& export APP_DESC=`jq -r '.description' appinfo.json` \
&& echo "Building fe-blogy..." \
&& cd /build/fe \
&& rm -rf .env \
&& rm -rf dist node_modules \
&& sed -i s/#{pageTitle}/"$APP_NAME v$APP_VERSION"/g public/index.html \
&& sed -i s/#{appName}/"$APP_NAME"/g public/index.html \
&& sed -i s/#{appInitial}/"$APP_INITIAL"/g public/index.html \
&& sed -i s/#{appShortname}/"$APP_SHORTNAME"/g public/index.html \
&& sed -i s/#{appDescription}/"$APP_DESC"/g public/index.html \
&& sed -i s/#{appVersion}/"$APP_VERSION"/g public/index.html \
&& sed -i s/#{appName}/"$APP_NAME"/g src/_shared/config.json \
&& sed -i s/#{appInitial}/"$APP_INITIAL"/g src/_shared/config.json \
&& sed -i s/#{appShortname}/"$APP_SHORTNAME"/g src/_shared/config.json \
&& sed -i s/#{appDescription}/"$APP_DESC"/g src/_shared/config.json \
&& sed -i s/#{appVersion}/"$APP_VERSION"/g src/_shared/config.json \
&& npm install && npm run build:blogy
FROM golang:1.19-alpine AS builder_be
RUN apk add git build-base jq sed
RUN mkdir /build
COPY . /build
RUN cd /build \
&& export APP_NAME=`jq -r '.name' appinfo.json` \
&& export APP_SHORTNAME=`jq -r '.shortname' appinfo.json` \
&& export APP_INITIAL=`jq -r '.initial' appinfo.json` \
&& export APP_VERSION=`jq -r '.version' appinfo.json` \
&& export APP_DESC=`jq -r '.description' appinfo.json` \
&& cd /build/be-api \
&& sed -i s/#{appName}/"$APP_NAME"/g config/application.conf \
&& sed -i s/#{appInitial}/"$APP_INITIAL"/g config/application.conf \
&& sed -i s/#{appShortname}/"$APP_SHORTNAME"/g config/application.conf \
&& sed -i s/#{appDescription}/"$APP_DESC"/g config/application.conf \
&& sed -i s/#{appVersion}/"$APP_VERSION"/g config/application.conf \
&& go build -o main
FROM alpine:3.17
LABEL maintainer="Thanh Nguyen <[email protected]>"
RUN mkdir -p /app/frontend
RUN mkdir -p /app/dodata
COPY --from=builder_be /build/be-api/main /app/main
COPY --from=builder_be /build/be-api/config /app/config
COPY --from=builder_fe_bootstrap /build/fe/dist/tpl-bootstrap /app/frontend/bootstrap
COPY --from=builder_fe_coderdocs /build/fe/dist/tpl-coderdocs /app/frontend/coderdocs
COPY --from=builder_fe_prettydocs /build/fe/dist/tpl-prettydocs /app/frontend/prettydocs
COPY --from=builder_fe_blogy /build/fe/dist/tpl-blogy /app/frontend/blogy
RUN apk add --no-cache -U tzdata bash ca-certificates \
&& update-ca-certificates \
&& cp /usr/share/zoneinfo/Asia/Ho_Chi_Minh /etc/localtime \
&& chmod 711 /app/main \
&& rm -rf /var/cache/apk/*
WORKDIR /app
EXPOSE 8000
CMD ["/app/main"]
#ENTRYPOINT /app/main