From 33a9a878f9545bb5aa9ed33b7fdaa64c5a3eb940 Mon Sep 17 00:00:00 2001 From: ljpsichuanuniversity <54525503+ljpsichuanuniversity@users.noreply.github.com> Date: Thu, 25 Jan 2024 22:43:30 +0800 Subject: [PATCH 1/5] support yum install postgresql (#8) * feat(dockerfile):update dockerfile support riscv64 * support yum install postgresql --------- Co-authored-by: 100ask --- .github/workflows/container.yml | 2 +- Dockerfile | 19 ++++++++++++++++--- 2 files changed, 17 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..4578ab3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,9 @@ -FROM postgres:12.16-alpine3.18 +FROM xfan1024/openeuler:23.03-light +RUN mkdir /tools +WORKDIR /tools -RUN apk --no-cache add tzdata dos2unix +# 安装依赖 +RUN yum -y install util-linux dos2unix ENV TZ=Asia/Shanghai @@ -12,4 +15,14 @@ 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 + + +RUN yum -y install postgresql postgresql-server \ + &&mkdir /data\ + &&chown -R postgres /data\ + &&chown -R postgres /tools + +USER postgres +RUN initdb -D /data \ + &&pg_ctl -D /data/ -l /data/logfile start \ No newline at end of file From fed81dd23b49225a974e65167f202346388db51b Mon Sep 17 00:00:00 2001 From: ljpsichuanuniversity <54525503+ljpsichuanuniversity@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:14:36 +0800 Subject: [PATCH 2/5] add entrypoint cmd (#10) * feat(dockerfile):update dockerfile support riscv64 * support postgresql service * support yum install postgresql * add entrypoint cmd --------- Co-authored-by: 100ask Co-authored-by: Chuang --- Dockerfile | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4578ab3..3e95404 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,11 @@ WORKDIR /tools # 安装依赖 RUN yum -y install util-linux dos2unix +RUN yum -y install postgresql postgresql-server \ + &&mkdir /data\ + &&chown -R postgres /data\ + &&chown -R postgres /tools + ENV TZ=Asia/Shanghai COPY ./update-pg-password.sh /usr/local/bin @@ -17,12 +22,9 @@ 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 +ENTRYPOINT ["docker-entrypoint.sh"] -RUN yum -y install postgresql postgresql-server \ - &&mkdir /data\ - &&chown -R postgres /data\ - &&chown -R postgres /tools +STOPSIGNAL SIGINT -USER postgres -RUN initdb -D /data \ - &&pg_ctl -D /data/ -l /data/logfile start \ No newline at end of file +EXPOSE 5432 +CMD ["postgres"] \ No newline at end of file From ec482003d9e185a686157b9cc489d2fce0699720 Mon Sep 17 00:00:00 2001 From: ljpsichuanuniversity <54525503+ljpsichuanuniversity@users.noreply.github.com> Date: Fri, 26 Jan 2024 16:43:09 +0800 Subject: [PATCH 3/5] postgresql support (#13) * feat(dockerfile):update dockerfile support riscv64 * support yum install postgresql * add entrypoint cmd * support su-exec --------- Co-authored-by: 100ask Co-authored-by: Chuang --- Dockerfile | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3e95404..bb24bcb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,18 @@ FROM xfan1024/openeuler:23.03-light RUN mkdir /tools WORKDIR /tools - # 安装依赖 -RUN yum -y install util-linux dos2unix - +RUN yum -y install util-linux dos2unix gcc make unzip wget\ + && wget https://github.com/ncopa/su-exec/archive/master.zip\ + && unzip master.zip\ + && cd su-exec-master\ + && make\ + && cp su-exec /usr/local/bin/ + RUN yum -y install postgresql postgresql-server \ &&mkdir /data\ &&chown -R postgres /data\ - &&chown -R postgres /tools + &&chown -R postgres /tools ENV TZ=Asia/Shanghai @@ -19,9 +23,11 @@ COPY docker-entrypoint.sh /usr/local/bin RUN dos2unix -k /usr/local/bin/update-pg-password.sh /usr/local/bin/docker-entrypoint.sh /docker-entrypoint-initdb.d/10_eulixspace.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh -RUN chmod +x /usr/local/bin/update-pg-password.sh +RUN chmod 777 /usr/local/bin/update-pg-password.sh RUN chmod +x /docker-entrypoint-initdb.d/10_eulixspace.sh +RUN chmod +x /usr/local/bin/su-exec +RUN chown -R postgres /usr/local/bin/docker-entrypoint.sh ENTRYPOINT ["docker-entrypoint.sh"] STOPSIGNAL SIGINT From 4bb3b2c660a3842890dc488d44a634742e43545f Mon Sep 17 00:00:00 2001 From: qww-ygg <79924801+qww-ygg@users.noreply.github.com> Date: Fri, 8 Mar 2024 09:37:21 +0000 Subject: [PATCH 4/5] change pgsql bind address --- docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index ec6dda3..b407f2a 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -325,7 +325,7 @@ _main() { docker_setup_db docker_process_init_files /docker-entrypoint-initdb.d/* - + sed -i "s/^#listen_addresses =.*$/listen_addresses = '*'/" "$PGDATA/postgresql.conf" docker_temp_server_stop unset PGPASSWORD From d8eaec4c8ae42bb8b44e18a1c80c145ed1c3130a Mon Sep 17 00:00:00 2001 From: qww-ygg <79924801+qww-ygg@users.noreply.github.com> Date: Fri, 8 Mar 2024 17:40:20 +0800 Subject: [PATCH 5/5] change pgsql bind address --- docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index b407f2a..5a69f30 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -325,7 +325,7 @@ _main() { docker_setup_db docker_process_init_files /docker-entrypoint-initdb.d/* - sed -i "s/^#listen_addresses =.*$/listen_addresses = '*'/" "$PGDATA/postgresql.conf" + sed -i "s/^#listen_addresses =.*$/listen_addresses = '*'/" "$PGDATA/postgresql.conf" docker_temp_server_stop unset PGPASSWORD