From 5a66b4d8f6f2673ab014a3342ae20499b57db546 Mon Sep 17 00:00:00 2001 From: souravbiswassanto <saurov@appscode.com> Date: Tue, 14 May 2024 16:10:05 +0600 Subject: [PATCH] Add apache age extension for postgres alpine image Signed-off-by: souravbiswassanto <saurov@appscode.com> --- .idea/.gitignore | 8 ----- .idea/modules.xml | 8 ----- .idea/postgres-docker.iml | 9 ----- .idea/vcs.xml | 6 ---- .idea/workspace.xml | 69 --------------------------------------- Dockerfile | 39 +++++++++++----------- example/README.md | 7 ++-- example/catalog.yaml | 14 ++++---- example/demo.yaml | 2 +- 9 files changed, 30 insertions(+), 132 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/modules.xml delete mode 100644 .idea/postgres-docker.iml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 28b4fe5..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="ProjectModuleManager"> - <modules> - <module fileurl="file://$PROJECT_DIR$/.idea/postgres-docker.iml" filepath="$PROJECT_DIR$/.idea/postgres-docker.iml" /> - </modules> - </component> -</project> \ No newline at end of file diff --git a/.idea/postgres-docker.iml b/.idea/postgres-docker.iml deleted file mode 100644 index 5e764c4..0000000 --- a/.idea/postgres-docker.iml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module type="WEB_MODULE" version="4"> - <component name="Go" enabled="true" /> - <component name="NewModuleRootManager"> - <content url="file://$MODULE_DIR$" /> - <orderEntry type="inheritedJdk" /> - <orderEntry type="sourceFolder" forTests="false" /> - </component> -</module> \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="VcsDirectoryMappings"> - <mapping directory="" vcs="Git" /> - </component> -</project> \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 46825c4..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,69 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="AutoImportSettings"> - <option name="autoReloadType" value="ALL" /> - </component> - <component name="ChangeListManager"> - <list default="true" id="3d5aa5c3-d06f-4f27-a207-3511d74a3cd6" name="Changes" comment=""> - <change afterPath="$PROJECT_DIR$/.idea/.gitignore" afterDir="false" /> - <change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" /> - <change afterPath="$PROJECT_DIR$/.idea/postgres-docker.iml" afterDir="false" /> - <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" /> - <change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/Dockerfile" beforeDir="false" afterPath="$PROJECT_DIR$/Dockerfile" afterDir="false" /> - </list> - <option name="SHOW_DIALOG" value="false" /> - <option name="HIGHLIGHT_CONFLICTS" value="true" /> - <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> - <option name="LAST_RESOLUTION" value="IGNORE" /> - </component> - <component name="GOROOT" url="file://$PROJECT_DIR$/../../../pkg/mod/golang.org/toolchain@v0.0.1-go1.21.6.linux-amd64" /> - <component name="Git.Settings"> - <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> - </component> - <component name="GoLibraries"> - <option name="indexEntireGoPath" value="true" /> - </component> - <component name="MarkdownSettingsMigration"> - <option name="stateVersion" value="1" /> - </component> - <component name="ProjectColorInfo">{ - "associatedIndex": 8 -}</component> - <component name="ProjectId" id="2c5GGvmGcBQidq2f8GJkxfrgqUf" /> - <component name="ProjectViewState"> - <option name="hideEmptyMiddlePackages" value="true" /> - <option name="showLibraryContents" value="true" /> - </component> - <component name="PropertiesComponent">{ - "keyToString": { - "RunOnceActivity.OpenProjectViewOnStart": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "RunOnceActivity.go.formatter.settings.were.checked": "true", - "RunOnceActivity.go.migrated.go.modules.settings": "true", - "RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true", - "go.import.settings.migrated": "true", - "go.sdk.automatically.set": "true", - "last_opened_file_path": "/home/user/go/src/kubedb.dev/postgres-docker", - "node.js.detected.package.eslint": "true", - "node.js.selected.package.eslint": "(autodetect)", - "nodejs_package_manager_path": "npm" - } -}</component> - <component name="SharedIndexes"> - <attachedChunks> - <set> - <option value="bundled-gosdk-33c477a475b1-e0158606a674-org.jetbrains.plugins.go.sharedIndexes.bundled-GO-241.15989.157" /> - <option value="bundled-js-predefined-1d06a55b98c1-91d5c284f522-JavaScript-GO-241.15989.157" /> - </set> - </attachedChunks> - </component> - <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" /> - <component name="TypeScriptGeneratedFilesManager"> - <option name="version" value="3" /> - </component> - <component name="VgoProject"> - <integration-enabled>false</integration-enabled> - <settings-migrated>true</settings-migrated> - </component> -</project> \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 0f30840..4f1b77d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,25 @@ -## Copyright The KubeDB Authors. -## -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. +# Copyright The KubeDB Authors. # -FROM postgres:15.5-bookworm AS builder +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM postgres:15.5-alpine as builder +RUN apk add --update alpine-sdk clang15-dev llvm15 perl postgresql15-dev bison libc-dev gcc git flex zlib-dev readline-dev build-base -RUN apt-get update \ - && apt-get install -y git build-essential postgresql-server-dev-15 libreadline-dev zlib1g-dev flex bison clang-14 RUN git clone https://github.com/apache/age.git \ && cd /age \ && git checkout release/PG15/1.5.0 \ - && make PG_CONFIG=/usr/bin/pg_config install + && make install PG_CONFIG=/usr/local/bin/pg_config -FROM postgres:15.5-bookworm -COPY --from=builder /usr/share/postgresql /usr/share/postgresql -COPY --from=builder /usr/lib/postgresql /usr/lib/postgresql +FROM postgres:15.5-alpine +COPY --from=builder /usr/local/share/postgresql /usr/local/share/postgresql +COPY --from=builder /usr/local/lib/postgresql /usr/local/lib/postgresql diff --git a/example/README.md b/example/README.md index 9d2611b..58fdbc8 100644 --- a/example/README.md +++ b/example/README.md @@ -5,18 +5,18 @@ 2. Create catalog.yaml ``` -kubectl apply -f https://github.com/kubedb/postgres-docker/raw/release-15.3-alpine-tds_fdw/example/catalog.yaml +kubectl apply -f https://raw.githubusercontent.com/kubedb/postgres-docker/15.5-bookworm-age/example/catalog.yaml ``` 3. Deploy a demo PostgreSQL database. ``` -kubectl apply -f https://github.com/kubedb/postgres-docker/raw/release-15.3-alpine-tds_fdw/example/demo.yaml +kubectl apply -f https://raw.githubusercontent.com/kubedb/postgres-docker/15.5-bookworm-age/example/demo.yaml ``` 4. Wait until postgres is ready. ```bash NAME VERSION STATUS AGE -postgres.kubedb.com/ha-postgres 15.5-bookworm Ready 22m +postgres.kubedb.com/ha-postgres 15.5 Ready 22m ``` 5. Exec into the pod and run psql command. @@ -24,7 +24,6 @@ postgres.kubedb.com/ha-postgres 15.5-bookworm Ready 22m kubectl exec -it -n demo ha-postgres-0 -- bash Defaulted container "postgres" out of: postgres, pg-coordinator, postgres-init-container (init) postgres@ha-postgres-0:/$ psql -psql (15.7 (Debian 15.7-1.pgdg120+1)) Type "help" for help. postgres=# diff --git a/example/catalog.yaml b/example/catalog.yaml index 60bb91c..a4c2090 100644 --- a/example/catalog.yaml +++ b/example/catalog.yaml @@ -1,7 +1,7 @@ apiVersion: catalog.kubedb.com/v1alpha1 kind: PostgresVersion metadata: - name: 15.5-bookworm + name: "15.5" spec: archiver: addon: @@ -14,12 +14,12 @@ spec: volumeSnapshot: name: volume-snapshot walg: - image: ghcr.io/kubedb/postgres-archiver:v0.6.0_15.5-bookworm + image: ghcr.io/kubedb/postgres-archiver:v0.6.0_15.5-alpine coordinator: image: ghcr.io/kubedb/pg-coordinator:v0.29.0 db: - baseOS: debian - image: souravbiswassanto/postgres-age-bookworm-okay:15 + baseOS: alpine + image: souravbiswassanto/postgres:15.5-alpine-age distribution: Official exporter: image: prometheuscommunity/postgres-exporter:v0.15.0 @@ -28,8 +28,8 @@ spec: podSecurityPolicies: databasePolicyName: postgres-db securityContext: - runAsAnyNonRoot: true - runAsUser: 999 + runAsAnyNonRoot: false + runAsUser: 70 stash: addon: backupTask: @@ -39,4 +39,4 @@ spec: updateConstraints: allowlist: - "14.2" - version: "15.5" \ No newline at end of file + version: "15.5" diff --git a/example/demo.yaml b/example/demo.yaml index 0cf4870..854a5da 100644 --- a/example/demo.yaml +++ b/example/demo.yaml @@ -4,7 +4,7 @@ metadata: name: ha-postgres namespace: demo spec: - version: "15.5-bookworm" + version: "15.5" replicas: 3 storageType: Durable storage: