Page MenuHomeMusing Studio

No OneTemporary

diff --git a/Dockerfile b/Dockerfile
index 6b92196..2a7bfd0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,48 +1,51 @@
# Build image
FROM golang:1.25-alpine3.22 AS build
LABEL org.opencontainers.image.source="https://github.com/writefreely/writefreely"
LABEL org.opencontainers.image.description="WriteFreely is a clean, minimalist publishing platform made for writers. Start a blog, share knowledge within your organization, or build a community around the shared act of writing."
RUN apk -U upgrade \
&& apk add --no-cache nodejs npm make g++ git \
&& npm install -g less less-plugin-clean-css \
&& mkdir -p /go/src/github.com/writefreely/writefreely
WORKDIR /go/src/github.com/writefreely/writefreely
COPY . .
RUN cat ossl_legacy.cnf > /etc/ssl/openssl.cnf
ENV GO111MODULE=on
ENV NODE_OPTIONS=--openssl-legacy-provider
RUN make build \
&& make ui \
&& mkdir /stage \
&& cp -R /go/bin \
/go/src/github.com/writefreely/writefreely/templates \
/go/src/github.com/writefreely/writefreely/static \
/go/src/github.com/writefreely/writefreely/pages \
/go/src/github.com/writefreely/writefreely/keys \
/go/src/github.com/writefreely/writefreely/cmd \
/stage
# Final image
FROM alpine:3.18.4
RUN apk -U upgrade \
&& apk add --no-cache openssl ca-certificates
COPY --from=build --chown=daemon:daemon /stage /go
WORKDIR /go
VOLUME /go/keys
EXPOSE 8080
USER daemon
ENTRYPOINT ["cmd/writefreely/writefreely"]
HEALTHCHECK --start-period=5s --interval=15s --timeout=5s \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/ || exit 1
+ COPY entrypoint.sh /entrypoint.sh
+RUN chmod +x /entrypoint.sh
+ENTRYPOINT ["/entrypoint.sh"]
diff --git a/entrypoint.sh b/entrypoint.sh
new file mode 100644
index 0000000..e021a4d
--- /dev/null
+++ b/entrypoint.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+set -e
+
+# 如果 config.ini 不存在,则根据环境变量生成
+if [ ! -f /app/config.ini ]; then
+cat > /app/config.ini << EOF
+[server]
+hidden_host =
+port = ${WRITEFREELY_BIND_PORT:-8080}
+bind = ${WRITEFREELY_BIND_HOST:-0.0.0.0}
+tls_cert_path =
+tls_key_path =
+autocert = false
+templates_parent_dir = /app
+static_parent_dir = /app
+pages_parent_dir = /app
+keys_parent_dir = /app
+[database]
+type = sqlite3
+filename = /app/writefreely.db
+username =
+password =
+database =
+host =
+port = 3306
+tls = false
+[app]
+site_name = ${WRITEFREELY_SITE_NAME:-My WriteFreely Blog}
+site_description =
+host = ${WRITEFREELY_HOST:-http://localhost:8080}
+theme = write
+editor =
+disable_js = false
+webfonts = true
+landing =
+simple_nav = false
+wf_modesty = false
+chorus = false
+disable_drafts = false
+single_user = ${WRITEFREELY_SINGLE_USER:-false}
+open_registration = ${WRITEFREELY_OPEN_REGISTRATION:-true}
+min_username_len = ${WRITEFREELY_MIN_USERNAME_LEN:-2}
+max_blogs = ${WRITEFREELY_MAX_BLOG:-1}
+federation = ${WRITEFREELY_FEDERATION:-true}
+public_stats = ${WRITEFREELY_PUBLIC_STATS:-true}
+private = ${WRITEFREELY_PRIVATE:-false}
+local_timeline = ${WRITEFREELY_LOCAL_TIMELINE:-false}
+user_invites = ${WRITEFREELY_USER_INVITES:-}
+default_visibility =
+EOF
+fi
+
+# 初始化数据库(首次运行)
+if [ ! -f /app/writefreely.db ]; then
+ /app/writefreely -c /app/config.ini --init-db
+ # 创建管理员账号
+ /app/writefreely -c /app/config.ini --create-admin "${WRITEFREELY_ADMIN_USER:-admin}:${WRITEFREELY_ADMIN_PASS:-changeme}"
+fi
+
+exec /app/writefreely -c /app/config.ini

File Metadata

Mime Type
text/x-diff
Expires
Thu, Mar 12, 8:51 PM (22 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3652504

Event Timeline