From 12cfcfbe2809c03f430ea4a86f783aa7aa00584f Mon Sep 17 00:00:00 2001 From: ljpsichuanuniversity <54525503+ljpsichuanuniversity@users.noreply.github.com> Date: Thu, 25 Jan 2024 20:20:50 +0800 Subject: [PATCH] support postgresql service (#6) * feat(dockerfile):update dockerfile support riscv64 Co-authored-by: 100ask --- .github/workflows/container.yml | 2 +- Dockerfile | 31 ++++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index 6cea02b..24d8558 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -168,7 +168,7 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} builder: ${{ steps.buildx.outputs.name }} - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64,linux/arm64,linux/riscv64 cache-from: type=gha cache-to: type=gha,mode=max file: Dockerfile diff --git a/Dockerfile b/Dockerfile index 4ea371e..ad38fb5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,10 @@ -FROM postgres:12.16-alpine3.18 +FROM xfan1024/openeuler:23.03-light -RUN apk --no-cache add tzdata dos2unix +RUN mkdir /tools +WORKDIR /tools + +# 安装依赖 +RUN yum -y install wget make gcc readline-devel zlib-devel util-linux tzdata dos2unix ENV TZ=Asia/Shanghai @@ -12,4 +16,25 @@ RUN dos2unix -k /usr/local/bin/update-pg-password.sh /usr/local/bin/docker-entry RUN chmod +x /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/update-pg-password.sh -RUN chmod +x /docker-entrypoint-initdb.d/10_eulixspace.sh \ No newline at end of file +RUN chmod +x /docker-entrypoint-initdb.d/10_eulixspace.sh + +# 下载并解压PostgreSQL源码 +RUN wget https://ftp.postgresql.org/pub/source/v12.16/postgresql-12.16.tar.gz +RUN tar -xvf postgresql-12.16.tar.gz + +# 编译和安装PostgreSQL +WORKDIR /tools/postgresql-12.16 +RUN ./configure --prefix=/usr/local/postgresql\ + && make -j16\ + && make install + +# 创建postgres用户和数据目录 +RUN useradd postgres\ + && mkdir /usr/local/postgresql/data\ + && chown -R postgres /usr/local/postgresql\ + && chown -R postgres /tools + +# 初始化数据库并启动PostgreSQL服务 +USER postgres +RUN /usr/local/postgresql/bin/initdb -D /usr/local/postgresql/data\ + && /usr/local/postgresql/bin/pg_ctl -D /usr/local/postgresql/data start \ No newline at end of file