修改docker部署方式
This commit is contained in:
1 parent
a6179aba6a
commit
16e5db3b26
16 files changed
+299
-95
No files matched your search
@@ -1,16 +0,0 @@
|
||||
*
|
||||
!Dockerfile
|
||||
!bin/
|
||||
!bin/chublog-api
|
||||
!bin/chusql-server
|
||||
!bin/csql-bootstrap
|
||||
!bin/libchusql_core_storage.so
|
||||
!sshd_config
|
||||
!gitconfig
|
||||
!authorized-keys.sh
|
||||
!ssh-entrypoint.sh
|
||||
!init-volumes.sh
|
||||
!db-entrypoint.sh
|
||||
!chusql.toml
|
||||
!hooks/
|
||||
!hooks/pre-receive
|
||||
+59
-13
@@ -1,10 +1,55 @@
|
||||
ARG DEBIAN_IMAGE=debian:trixie-slim
|
||||
ARG DEBIAN_IMAGE=mirror.ccs.tencentyun.com/library/debian:trixie-slim
|
||||
ARG RUST_IMAGE=mirror.ccs.tencentyun.com/library/rust:1-trixie
|
||||
|
||||
ARG HASKELL_IMAGE=mirror.ccs.tencentyun.com/library/haskell:9.10.3-slim-bookworm
|
||||
|
||||
FROM ${HASKELL_IMAGE} AS haskell-toolchain
|
||||
|
||||
FROM ${RUST_IMAGE} AS rust-toolchain
|
||||
ENV CARGO_BUILD_JOBS=2
|
||||
ARG CARGO_MIRROR_INDEX=sparse+https://rsproxy.cn/index/
|
||||
RUN if [ -n "$CARGO_MIRROR_INDEX" ]; then \
|
||||
printf '[source.crates-io]\nreplace-with = "build-mirror"\n[source.build-mirror]\nregistry = "%s"\n' \
|
||||
"$CARGO_MIRROR_INDEX" > /usr/local/cargo/config.toml; \
|
||||
fi
|
||||
|
||||
FROM rust-toolchain AS rust-build
|
||||
WORKDIR /src
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY apps/api ./apps/api
|
||||
COPY external/ChuSQL-RustDriver ./external/ChuSQL-RustDriver
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/usr/local/cargo/git \
|
||||
cargo build --locked --release && mkdir /out && cp target/release/chublog-api /out/
|
||||
|
||||
FROM rust-toolchain AS database-build
|
||||
ARG DEBIAN_MIRROR=mirrors.tencentyun.com
|
||||
RUN sed -i "s|deb.debian.org|${DEBIAN_MIRROR}|g" /etc/apt/sources.list.d/debian.sources \
|
||||
&& apt-get update && apt-get install -y --no-install-recommends \
|
||||
binutils-gold pkg-config libgmp-dev libffi-dev zlib1g-dev libnuma-dev libtinfo6 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
# GHC version must match the pinned ChuSQL Stack resolver.
|
||||
COPY --from=haskell-toolchain /opt/ghc/9.10.3 /opt/ghc/9.10.3
|
||||
COPY --from=haskell-toolchain /usr/local/bin/stack /usr/local/bin/stack
|
||||
ENV PATH=/opt/ghc/9.10.3/bin:$PATH
|
||||
WORKDIR /src/ChuSQL
|
||||
COPY external/ChuSQL ./
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
cargo build --manifest-path chusql-core/storage/Cargo.toml --locked --release
|
||||
ENV LD_LIBRARY_PATH=/src/ChuSQL/chusql-core/storage/target/release
|
||||
RUN --mount=type=cache,target=/root/.stack \
|
||||
mkdir /out && cd chusql-server \
|
||||
&& stack --system-ghc --no-install-ghc --no-terminal --jobs 2 build --fast --copy-bins --local-bin-path /out \
|
||||
&& cd ../chusql-bootstrap \
|
||||
&& stack --system-ghc --no-install-ghc --no-terminal --jobs 2 build --fast --copy-bins --local-bin-path /out \
|
||||
&& cp ../chusql-core/storage/target/release/libchusql_core_storage.so /out/
|
||||
|
||||
FROM ${DEBIAN_IMAGE} AS base
|
||||
ARG DEBIAN_MIRROR=deb.debian.org
|
||||
ARG DEBIAN_MIRROR=mirrors.tencentyun.com
|
||||
RUN sed -i "s|deb.debian.org|${DEBIAN_MIRROR}|g" /etc/apt/sources.list.d/debian.sources
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates libgmp10 curl util-linux && rm -rf /var/lib/apt/lists/*
|
||||
COPY bin/chublog-api /usr/local/bin/chublog-api
|
||||
COPY gitconfig /etc/chublog/gitconfig
|
||||
COPY --from=rust-build /out/chublog-api /usr/local/bin/chublog-api
|
||||
COPY deploy/gitconfig /etc/chublog/gitconfig
|
||||
RUN groupadd -g 10002 ingress && useradd -u 10001 -g ingress -M -s /usr/sbin/nologin blog
|
||||
|
||||
FROM base AS api
|
||||
@@ -14,26 +59,27 @@ ENTRYPOINT ["chublog-api"]
|
||||
|
||||
FROM base AS ssh
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends openssh-server && rm -rf /var/lib/apt/lists/* && useradd -u 10002 -g ingress -M -d /srv/ingress -s /bin/sh git && passwd -d git
|
||||
COPY sshd_config /etc/ssh/sshd_config
|
||||
COPY hooks /hooks
|
||||
COPY ssh-entrypoint.sh /usr/local/bin/ssh-entrypoint
|
||||
COPY authorized-keys.sh /usr/local/bin/chublog-authorized-keys
|
||||
COPY deploy/sshd_config /etc/ssh/sshd_config
|
||||
COPY deploy/hooks /hooks
|
||||
COPY deploy/ssh-entrypoint.sh /usr/local/bin/ssh-entrypoint
|
||||
COPY deploy/authorized-keys.sh /usr/local/bin/chublog-authorized-keys
|
||||
RUN chmod 755 /hooks/pre-receive /usr/local/bin/ssh-entrypoint /usr/local/bin/chublog-authorized-keys
|
||||
ENTRYPOINT ["/usr/local/bin/ssh-entrypoint"]
|
||||
|
||||
FROM base AS init
|
||||
COPY init-volumes.sh /usr/local/bin/init-volumes
|
||||
COPY deploy/init-volumes.sh /usr/local/bin/init-volumes
|
||||
RUN chmod 755 /usr/local/bin/init-volumes
|
||||
ENTRYPOINT ["/usr/local/bin/init-volumes"]
|
||||
|
||||
FROM ${DEBIAN_IMAGE} AS database
|
||||
ARG DEBIAN_MIRROR=deb.debian.org
|
||||
ARG DEBIAN_MIRROR=mirrors.tencentyun.com
|
||||
RUN sed -i "s|deb.debian.org|${DEBIAN_MIRROR}|g" /etc/apt/sources.list.d/debian.sources
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends libgmp10 ca-certificates && rm -rf /var/lib/apt/lists/* && useradd -u 10003 -M -s /usr/sbin/nologin chusql
|
||||
COPY bin/chusql-server bin/csql-bootstrap bin/libchusql_core_storage.so /usr/local/bin/
|
||||
COPY chusql.toml /etc/chusql/settings.toml
|
||||
COPY db-entrypoint.sh /usr/local/bin/db-entrypoint
|
||||
COPY --from=database-build /out/chusql-server /out/csql-bootstrap /out/libchusql_core_storage.so /usr/local/bin/
|
||||
COPY deploy/chusql.toml /etc/chusql/settings.toml
|
||||
COPY deploy/db-entrypoint.sh /usr/local/bin/db-entrypoint
|
||||
RUN chmod 755 /usr/local/bin/db-entrypoint
|
||||
ENV LD_LIBRARY_PATH=/usr/local/bin
|
||||
RUN chusql-server --help && csql-bootstrap --help
|
||||
USER 10003:10003
|
||||
ENTRYPOINT ["/usr/local/bin/db-entrypoint"]
|
||||
+20
-7
@@ -4,9 +4,18 @@ x-logging: &logging
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
x-backend-build: &backend-build
|
||||
context: ..
|
||||
dockerfile: deploy/Dockerfile
|
||||
args:
|
||||
DEBIAN_MIRROR: ${DEBIAN_MIRROR:-mirrors.tencentyun.com}
|
||||
DEBIAN_IMAGE: ${REGISTRY_PREFIX-mirror.ccs.tencentyun.com/library/}debian:trixie-slim
|
||||
RUST_IMAGE: ${REGISTRY_PREFIX-mirror.ccs.tencentyun.com/library/}rust:1-trixie
|
||||
HASKELL_IMAGE: ${REGISTRY_PREFIX-mirror.ccs.tencentyun.com/library/}haskell:9.10.3-slim-bookworm
|
||||
CARGO_MIRROR_INDEX: ${CARGO_MIRROR_INDEX-sparse+https://rsproxy.cn/index/}
|
||||
services:
|
||||
init:
|
||||
build: { context: ., target: init, args: { DEBIAN_MIRROR: "${DEBIAN_MIRROR:-deb.debian.org}", DEBIAN_IMAGE: "${REGISTRY_PREFIX:-}debian:trixie-slim" } }
|
||||
build: { <<: *backend-build, target: init }
|
||||
volumes:
|
||||
- content:/data
|
||||
- authorization:/auth
|
||||
@@ -17,7 +26,7 @@ services:
|
||||
network_mode: none
|
||||
logging: *logging
|
||||
api:
|
||||
build: { context: ., target: api, args: { DEBIAN_MIRROR: "${DEBIAN_MIRROR:-deb.debian.org}", DEBIAN_IMAGE: "${REGISTRY_PREFIX:-}debian:trixie-slim" } }
|
||||
build: { <<: *backend-build, target: api }
|
||||
depends_on:
|
||||
init: { condition: service_completed_successfully }
|
||||
environment:
|
||||
@@ -49,7 +58,11 @@ services:
|
||||
retries: 3
|
||||
logging: *logging
|
||||
web:
|
||||
build: { context: ../apps/web, args: { NODE_IMAGE: "${REGISTRY_PREFIX:-}node:24-bookworm-slim" } }
|
||||
build:
|
||||
context: ../apps/web
|
||||
args:
|
||||
NODE_IMAGE: ${REGISTRY_PREFIX-mirror.ccs.tencentyun.com/library/}node:24-bookworm-slim
|
||||
NPM_REGISTRY: ${NPM_REGISTRY:-https://mirrors.tencentyun.com/npm/}
|
||||
depends_on:
|
||||
api: { condition: service_healthy }
|
||||
environment:
|
||||
@@ -73,7 +86,7 @@ services:
|
||||
retries: 3
|
||||
logging: *logging
|
||||
ssh:
|
||||
build: { context: ., target: ssh, args: { DEBIAN_MIRROR: "${DEBIAN_MIRROR:-deb.debian.org}", DEBIAN_IMAGE: "${REGISTRY_PREFIX:-}debian:trixie-slim" } }
|
||||
build: { <<: *backend-build, target: ssh }
|
||||
depends_on:
|
||||
init: { condition: service_completed_successfully }
|
||||
api: { condition: service_healthy }
|
||||
@@ -96,7 +109,7 @@ services:
|
||||
restart: unless-stopped
|
||||
logging: *logging
|
||||
db:
|
||||
build: { context: ., target: database, args: { DEBIAN_MIRROR: "${DEBIAN_MIRROR:-deb.debian.org}", DEBIAN_IMAGE: "${REGISTRY_PREFIX:-}debian:trixie-slim" } }
|
||||
build: { <<: *backend-build, target: database }
|
||||
depends_on:
|
||||
init: { condition: service_completed_successfully }
|
||||
environment:
|
||||
@@ -115,7 +128,7 @@ services:
|
||||
restart: unless-stopped
|
||||
logging: *logging
|
||||
db-init:
|
||||
build: { context: ., target: api, args: { DEBIAN_MIRROR: "${DEBIAN_MIRROR:-deb.debian.org}", DEBIAN_IMAGE: "${REGISTRY_PREFIX:-}debian:trixie-slim" } }
|
||||
build: { <<: *backend-build, target: api }
|
||||
profiles: [setup]
|
||||
entrypoint: [chublog-api, provision-db]
|
||||
environment:
|
||||
@@ -130,7 +143,7 @@ services:
|
||||
restart: "no"
|
||||
logging: *logging
|
||||
caddy:
|
||||
image: ${REGISTRY_PREFIX:-}caddy:2
|
||||
image: ${REGISTRY_PREFIX-mirror.ccs.tencentyun.com/library/}caddy:2
|
||||
environment:
|
||||
SITE_ADDRESS: ${SITE_ADDRESS:-localhost}
|
||||
ports: ["${HTTP_BIND:-0.0.0.0}:${HTTP_PORT:-80}:80", "${HTTP_BIND:-0.0.0.0}:${HTTPS_PORT:-443}:443"]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# Build/test overrides only; contains no credentials or production settings.
|
||||
REGISTRY_PREFIX=public.ecr.aws/docker/library/
|
||||
DEBIAN_MIRROR=mirrors.ustc.edu.cn
|
||||
NPM_REGISTRY=https://registry.npmjs.org/
|
||||
CARGO_MIRROR_INDEX=sparse+https://rsproxy.cn/index/
|
||||
Reference in new issue
Block a user