[英]Install pl/sh on a postgres-alpine container
我有一個 postgres 服務器在圖像postgres:9.6-alpine
的 docker 容器中運行。 我想寫一個執行一些 sh 命令的 postgres 函數。 為此,我想在下面的函數中聲明語言 plsh:
CREATE or REPLACE FUNCTION func2 (var1 text) RETURNS text AS '
#!/bin/bash
touch /home/postgres/$1;
' LANGUAGE plsh;
commit;
我沒有安裝該語言,因為它是 postgres 的外部項目。 有沒有辦法在高山上安裝它? 這是repo的鏈接。
是的,有可能。 plsh
postgres 擴展應該從源代碼構建。
Dockerfile
是:
FROM postgres:9.6-alpine
RUN apk add --no-cache git g++ make
RUN git clone https://github.com/petere/plsh && \
cd plsh && \
make && \
make install
這個Dockerfile
適用於 PostgreSQL13
FROM postgres:13-alpine
RUN apk add --no-cache git g++ make clang llvm10
RUN git clone https://github.com/petere/plsh && \
cd plsh && \
make && \
make install
構建鏡像docker build --tag plsh:13.
旋轉一個容器並測試它
CREATE EXTENSION IF NOT EXISTS plsh;
CREATE OR REPLACE FUNCTION hello (who TEXT) RETURNS text
LANGUAGE plsh
AS $$
#!/bin/sh
echo "Hello, $1 !"
return 0;
$$;
SELECT hello(who:='world');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.