diff --git a/go/1.17.3/22.03-lts/Dockerfile b/go/1.17.3/22.03-lts/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..14f59e569218ae80625a6f0b85d2e66162c07c1f --- /dev/null +++ b/go/1.17.3/22.03-lts/Dockerfile @@ -0,0 +1,10 @@ +FROM openeuler/openeuler:22.03-lts +MAINTAINER heguofeng +RUN yum -y update \ + && yum -y install go \ + && yum clean all + +ENV GOPATH /go +ENV PATH $GOPATH/bin:$PATH +RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" +WORKDIR $GOPATH diff --git a/go/README.md b/go/README.md new file mode 100644 index 0000000000000000000000000000000000000000..0359002c995eafe0b4d395300d3b197cb97acacd --- /dev/null +++ b/go/README.md @@ -0,0 +1,53 @@ +#golang + + +# Quick reference + +- The official golang docker image. + +- Maintained by: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative) + +- Where to get help: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative), [openEuler](https://gitee.com/openeuler/community) + +# Build reference + +1. Build images and push: +```shell +docker buildx build -t "openeuler/golang:$VERSION" --platform linux/amd64,linux/arm64 . --push +``` + +We are using `buildx` in here to generate multi-arch images, see more in [Docker Buildx](https://docs.docker.com/buildx/working-with-buildx/) + +2. Run: +```shell +docker run -d openeuler/golang:1.17.3 +``` + +# How to use this image +## Start a Go instance in your app +The most staightforward way to use this image is to use a Go container as both the build and runtime enviroment. +In your Dockfile, writhing something along the lines of the following will compile and run your project. +```shell +FROM openeuler/golang:1.17.3 + +WORKDIR /app + +COPY go.mod go.sum ./ +RUN go mod download && go mod verify +COPY . . +RUN go build -v -o /usr/local/bin/app ./... + +CMD ["app"] +``` +You can then build and run the Docker image: +```shell +docker build -t my-golang-app . +docker run -it --rm --name my_app my-golang-app +``` + +# Supported tags and respective Dockerfile links + +- 1.17.3-22.03-lts: golang v1.17.3, openEuler 22.03 LTS + +## Operating System +Linux/Unix, ARM64 or x86-64 architecture. diff --git a/opengauss-lite/2.1.0/22.03-lts/Dockerfile b/opengauss-lite/2.1.0/22.03-lts/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b2eed2bc8ee9a30ba3cb2d9bddd75812d0e9904b --- /dev/null +++ b/opengauss-lite/2.1.0/22.03-lts/Dockerfile @@ -0,0 +1,29 @@ +FROM openeuler/openeuler:22.03-lts +MAINTAINER heguofeng +RUN yum -y update && \ + yum -y install sudo util-linux lsof && \ + yum -y install opengauss && \ + su - opengauss -c "gs_ctl stop -D /var/lib/opengauss/data -mf " && \ + rm -rf /var/lib/opengauss/data && \ + sed -i 's/7654/5432/g' /var/lib/opengauss/.bash_profile && \ + sed -i "s/listen_addresses = '127.0.0.1'/listen_addresses = '0.0.0.0'/g" /usr/local/opengauss/share/postgresql/postgresql.conf.sample && \ + sed -i 's/port = 7654/port = 5432/g' /usr/local/opengauss/share/postgresql/postgresql.conf.sample && \ + mkdir /docker-entrypoint-initdb.d && \ + chown opengauss:opengauss /docker-entrypoint-initdb.d && \ + yum clean all + +COPY gosu-amd64 /usr/local/bin/gosu_amd64 +COPY gosu-arm64 /usr/local/bin/gosu_arm64 + +ENV GOSU_VERSION 1.12 +RUN set -eux; \ + chmod +x /usr/local/bin/gosu_amd64 && \ + chmod +x /usr/local/bin/gosu_arm64 + +ENV PGDATA /var/lib/opengauss/data +COPY entrypoint.sh /var/lib/opengauss/ +RUN chmod 755 /var/lib/opengauss/entrypoint.sh + +ENTRYPOINT ["/var/lib/opengauss/entrypoint.sh"] +EXPOSE 5432 +CMD [ "gaussdb" ] diff --git a/opengauss-lite/2.1.0/22.03-lts/entrypoint.sh b/opengauss-lite/2.1.0/22.03-lts/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..fb464ee9a4d5a697eaebcbf640f85fd6dce7b3b5 --- /dev/null +++ b/opengauss-lite/2.1.0/22.03-lts/entrypoint.sh @@ -0,0 +1,412 @@ +#!/usr/bin/env bash +set -Eeo pipefail + +# usage: file_env VAR [DEFAULT] +# ie: file_env 'XYZ_DB_PASSWORD' 'example' +# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of +# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) + +export GAUSSHOME=/usr/local/opengauss +export PATH=$GAUSSHOME/bin:$PATH +export LD_LIBRARY_PATH=$GAUSSHOME/lib:$LD_LIBRARY_PATH + +arch=$(case $(uname -m) in i386) echo "386" ;; i686) echo "386" ;; x86_64) echo "amd64";; aarch64)echo "arm64";; esac) +if [ "${arch}" = "amd64" ]; then + GOSU_EXEC=/usr/local/bin/gosu_amd64 +else + GOSU_EXEC=/usr/local/bin/gosu_arm64 +fi +if [ ! -f /usr/local/bin/gosu ]; then + ln -s ${GOSU_EXEC} /usr/local/bin/gosu +fi + +file_env() { + local var="$1" + local fileVar="${var}_FILE" + local def="${2:-}" + if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then + echo >&2 "error: both $var and $fileVar are set (but are exclusive)" + exit 1 + fi + local val="$def" + if [ "${!var:-}" ]; then + val="${!var}" + elif [ "${!fileVar:-}" ]; then + val="$(< "${!fileVar}")" + fi + export "$var"="$val" + unset "$fileVar" +} + +# check to see if this file is being run or sourced from another script +_is_sourced() { + [ "${#FUNCNAME[@]}" -ge 2 ] \ + && [ "${FUNCNAME[0]}" = '_is_sourced' ] \ + && [ "${FUNCNAME[1]}" = 'source' ] +} + +# used to create initial opengauss directories and if run as root, ensure ownership belong to the opengauss user +docker_create_db_directories() { + local user; user="$(id -u)" + + mkdir -p "$PGDATA" + chmod 700 "$PGDATA" + + # ignore failure since it will be fine when using the image provided directory; + mkdir -p /var/run/opengauss || : + chmod 775 /var/run/opengauss || : + + # Create the transaction log directory before initdb is run so the directory is owned by the correct user + if [ -n "$POSTGRES_INITDB_XLOGDIR" ]; then + mkdir -p "$POSTGRES_INITDB_XLOGDIR" + if [ "$user" = '0' ]; then + find "$POSTGRES_INITDB_XLOGDIR" \! -user opengauss -exec chown opengauss '{}' + + fi + chmod 700 "$POSTGRES_INITDB_XLOGDIR" + fi + + # allow the container to be started with `--user` + if [ "$user" = '0' ]; then + find "$PGDATA" \! -user opengauss -exec chown opengauss '{}' + + find /var/run/opengauss \! -user opengauss -exec chown opengauss '{}' + + fi +} + +# initialize empty PGDATA directory with new database via 'initdb' +# arguments to `initdb` can be passed via POSTGRES_INITDB_ARGS or as arguments to this function +# `initdb` automatically creates the "postgres", "template0", and "template1" dbnames +# this is also where the database user is created, specified by `GS_USER` env +docker_init_database_dir() { + # "initdb" is particular about the current user existing in "/etc/passwd", so we use "nss_wrapper" to fake that if necessary + if ! getent passwd "$(id -u)" &> /dev/null && [ -e /usr/lib/libnss_wrapper.so ]; then + export LD_PRELOAD='/usr/lib/libnss_wrapper.so' + export NSS_WRAPPER_PASSWD="$(mktemp)" + export NSS_WRAPPER_GROUP="$(mktemp)" + echo "postgres:x:$(id -u):$(id -g):PostgreSQL:$PGDATA:/bin/false" > "$NSS_WRAPPER_PASSWD" + echo "postgres:x:$(id -g):" > "$NSS_WRAPPER_GROUP" + fi + + if [ -n "$POSTGRES_INITDB_XLOGDIR" ]; then + set -- --xlogdir "$POSTGRES_INITDB_XLOGDIR" "$@" + fi + + if [ -n "$GS_NODENAME" ]; then + eval 'gs_initdb --pwfile=<(echo "$GS_PASSWORD") --nodename=$GS_NODENAME -D $PGDATA' + else + eval 'gs_initdb --pwfile=<(echo "$GS_PASSWORD") --nodename=gaussdb -D $PGDATA' + fi + if [ "${LD_PRELOAD:-}" = '/usr/lib/libnss_wrapper.so' ]; then + rm -f "$NSS_WRAPPER_PASSWD" "$NSS_WRAPPER_GROUP" + unset LD_PRELOAD NSS_WRAPPER_PASSWD NSS_WRAPPER_GROUP + fi +} + +# print large warning if GS_PASSWORD is long +# error if both GS_PASSWORD is empty and GS_HOST_AUTH_METHOD is not 'trust' +# print large warning if GS_HOST_AUTH_METHOD is set to 'trust' +# assumes database is not set up, ie: [ -z "$DATABASE_ALREADY_EXISTS" ] +docker_verify_minimum_env() { + # check password first so we can output the warning before postgres + # messes it up + if [[ "$GS_PASSWORD" =~ ^(.{8,}).*$ ]] && [[ "$GS_PASSWORD" =~ ^(.*[a-z]+).*$ ]] && [[ "$GS_PASSWORD" =~ ^(.*[A-Z]).*$ ]] && [[ "$GS_PASSWORD" =~ ^(.*[0-9]).*$ ]] && [[ "$GS_PASSWORD" =~ ^(.*[#?!@$%^&*-]).*$ ]]; then + cat >&2 <<-'EOWARN' + + Message: The supplied GS_PASSWORD is meet requirements. + +EOWARN + else + cat >&2 <<-'EOWARN' + + Error: The supplied GS_PASSWORD is not meet requirements. + Please Check if the password contains uppercase, lowercase, numbers, special characters, and password length(8). + At least one uppercase, lowercase, numeric, special character. + Example: openGauss@123 +EOWARN + exit 1 + fi + if [ -z "$GS_PASSWORD" ] && [ 'trust' != "$GS_HOST_AUTH_METHOD" ]; then + # The - option suppresses leading tabs but *not* spaces. :) + cat >&2 <<-'EOE' + Error: Database is uninitialized and superuser password is not specified. + You must specify GS_PASSWORD to a non-empty value for the + superuser. For example, "-e GS_PASSWORD=password" on "docker run". + + You may also use "GS_HOST_AUTH_METHOD=trust" to allow all + connections without a password. This is *not* recommended. + +EOE + exit 1 + fi + if [ 'trust' = "$GS_HOST_AUTH_METHOD" ]; then + cat >&2 <<-'EOWARN' + ******************************************************************************** + WARNING: GS_HOST_AUTH_METHOD has been set to "trust". This will allow + anyone with access to the opengauss port to access your database without + a password, even if GS_PASSWORD is set. + It is not recommended to use GS_HOST_AUTH_METHOD=trust. Replace + it with "-e GS_PASSWORD=password" instead to set a password in + "docker run". + ******************************************************************************** +EOWARN + fi +} + +# usage: docker_process_init_files [file [file [...]]] +# ie: docker_process_init_files /always-initdb.d/* +# process initializer files, based on file extensions and permissions +docker_process_init_files() { + # gsql here for backwards compatiblilty "${gsql[@]}" + gsql=( docker_process_sql ) + + echo + local f + for f; do + case "$f" in + *.sh) + if [ -x "$f" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; + *.sql) echo "$0: running $f"; docker_process_sql -f "$f"; echo ;; + *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | docker_process_sql; echo ;; + *.sql.xz) echo "$0: running $f"; xzcat "$f" | docker_process_sql; echo ;; + *) echo "$0: ignoring $f" ;; + esac + echo + done +} + +# Execute sql script, passed via stdin (or -f flag of pqsl) +# usage: docker_process_sql [gsql-cli-args] +# ie: docker_process_sql --dbname=mydb <<<'INSERT ...' +# ie: docker_process_sql -f my-file.sql +# ie: docker_process_sql > "$PGDATA/pg_hba.conf" +} + +# append parameter to postgres.conf for connections +opengauss_setup_postgresql_conf() { + { + echo + if [ -n "$GS_PORT" ]; then + echo "password_encryption_type = 0" + echo "port = $GS_PORT" + echo "wal_level = logical" + else + echo '# use default port 5432' + echo "password_encryption_type = 0" + echo "wal_level = logical" + fi + + if [ -n "$SERVER_MODE" ]; then + echo "listen_addresses = '0.0.0.0'" + echo "most_available_sync = on" + echo "remote_read_mode = non_authentication" + echo "pgxc_node_name = '$NODE_NAME'" + # echo "application_name = '$NODE_NAME'" + if [ "$SERVER_MODE" = "primary" ]; then + echo "max_connections = 100" + else + echo "max_connections = 100" + fi + echo -e "$REPL_CONN_INFO" + if [ -n "$SYNCHRONOUS_STANDBY_NAMES" ]; then + echo "synchronous_standby_names=$SYNCHRONOUS_STANDBY_NAMES" + fi + else + echo "listen_addresses = '*'" + fi + + if [ -n "$OTHER_PG_CONF" ]; then + echo -e "$OTHER_PG_CONF" + fi + } >> "$PGDATA/postgresql.conf" +} + +opengauss_setup_mot_conf() { + echo "enable_numa = false" >> "$PGDATA/mot.conf" +} + +# start socket-only postgresql server for setting up or running scripts +# all arguments will be passed along as arguments to `postgres` (via pg_ctl) +docker_temp_server_start() { + if [ "$1" = 'gaussdb' ]; then + shift + fi + + # internal start of server in order to allow setup using gsql client + # does not listen on external TCP/IP and waits until start finishes + set -- "$@" -c listen_addresses='' -p "${PGPORT:-5432}" + + PGUSER="${PGUSER:-$GS_USER}" \ + gs_ctl -D "$PGDATA" \ + -o "$(printf '%q ' "$@")" \ + -w start +} + +# stop postgresql server after done setting up user and running scripts +docker_temp_server_stop() { + PGUSER="${PGUSER:-postgres}" \ + gs_ctl -D "$PGDATA" -m fast -w stop +} + +_opengauss_want_help() { + local arg + count=1 + for arg; do + case "$arg" in + # postgres --help | grep 'then exit' + # leaving out -C on purpose since it always fails and is unhelpful: + # postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory + -'?'|--help|--describe-config|-V|--version) + return 0 + ;; + esac + if [ "$arg" == "-M" ]; then + SERVER_MODE=${@:$count+1:1} + echo "openGauss DB SERVER_MODE = $SERVER_MODE" + shift + fi + count=$[$count + 1] + done + return 1 +} + +_main() { + # if first arg looks like a flag, assume we want to run postgres server + if [ "${1:0:1}" = '-' ]; then + set -- gaussdb "$@" + fi + + if [ "$1" = 'gaussdb' ] && ! _opengauss_want_help "$@"; then + docker_setup_env + # setup data directories and permissions (when run as root) + docker_create_db_directories + if [ "$(id -u)" = '0' ]; then + # then restart script as postgres user + exec gosu opengauss "$BASH_SOURCE" "$@" + fi + + # only run initialization on an empty data directory + if [ -z "$DATABASE_ALREADY_EXISTS" ]; then + docker_verify_minimum_env + + # check dir permissions to reduce likelihood of half-initialized database + ls /docker-entrypoint-initdb.d/ > /dev/null + + docker_init_database_dir + opengauss_setup_hba_conf + opengauss_setup_postgresql_conf + opengauss_setup_mot_conf + + # PGPASSWORD is required for gsql when authentication is required for 'local' connections via pg_hba.conf and is otherwise harmless + # e.g. when '--auth=md5' or '--auth-local=md5' is used in POSTGRES_INITDB_ARGS + export PGPASSWORD="${PGPASSWORD:-$GS_PASSWORD}" + docker_temp_server_start "$@" + if [ -z "$SERVER_MODE" ] || [ "$SERVER_MODE" = "primary" ]; then + docker_setup_db + docker_setup_user + docker_setup_rep_user + docker_process_init_files /docker-entrypoint-initdb.d/* + fi + + docker_temp_server_stop + unset PGPASSWORD + + echo + echo 'openGauss init process complete; ready for start up.' + echo + else + echo + echo 'openGauss Database directory appears to contain a database; Skipping initialization' + echo + fi + fi + exec "$@" +} + +if ! _is_sourced; then + _main "$@" +fi + diff --git a/opengauss-lite/2.1.0/22.03-lts/gosu-amd64 b/opengauss-lite/2.1.0/22.03-lts/gosu-amd64 new file mode 100644 index 0000000000000000000000000000000000000000..834951f8910b8f4f88d626a05c9c0cdce527f967 Binary files /dev/null and b/opengauss-lite/2.1.0/22.03-lts/gosu-amd64 differ diff --git a/opengauss-lite/2.1.0/22.03-lts/gosu-arm64 b/opengauss-lite/2.1.0/22.03-lts/gosu-arm64 new file mode 100644 index 0000000000000000000000000000000000000000..925e16ed1ff020e522c815ae4b6b8349634ef30a Binary files /dev/null and b/opengauss-lite/2.1.0/22.03-lts/gosu-arm64 differ diff --git a/opengauss-lite/README.md b/opengauss-lite/README.md new file mode 100644 index 0000000000000000000000000000000000000000..516b533f28605bb537898d3b56c74159c7e0beba --- /dev/null +++ b/opengauss-lite/README.md @@ -0,0 +1,42 @@ +# openGauss-lite + +# Quick reference + +- The official openGauss-lite docker image. + +- Maintained by: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative) + +- Where to get help: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative), [openEuler](https://gitee.com/openeuler/community) + +# Build reference + +1. Build images and push: +```shell +docker buildx build -t "openeuler/opengauss-lite:$VERSION" --platform linux/amd64,linux/arm64 . --push +``` + +We are using `buildx` in here to generate multi-arch images, see more in [Docker Buildx](https://docs.docker.com/buildx/working-with-buildx/) + +# How to use this image +## start a openGauss instance +```shell +docker run --name opengauss --privileged=true -d -e GS_PASSWORD=openGauss@123 openeuler/opengauss-lite:2.1.0 +``` + +## connect database using gsql from os +```shell +docker run --name opengauss --privileged=true -d -e GS_PASSWORD=openGauss@123 -p5433:5432 openeuler/opengauss-lite:2.1.0 +gsql -d postgres -U gaussdb -W 'openGauss@123' -h host_ip -p 5433 +``` + +## persist data to local storage +```shell +docker run --name opengauss --privileged=true -d -e GS_PASSWORD=openGauss@123 -v /opengauss:/var/lib/opengauss/data openeuler/opengauss-lite:2.1.0 +``` + +# Supported tags and respective Dockerfile links + +- 2.1.0-22.03-lts: openGauss-lite v2.1.0, openEuler 22.03 LTS + +## Operating System +Linux/Unix, ARM64 or x86-64 architecture. diff --git a/postgres/13.3/22.03-lts/Dockerfile b/postgres/13.3/22.03-lts/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e5d3cfa71c5416bbb73a681771fd7ae451faaa8a --- /dev/null +++ b/postgres/13.3/22.03-lts/Dockerfile @@ -0,0 +1,26 @@ +FROM openeuler/openeuler:22.03-lts +MAINTAINER heguofeng +RUN yum -y update && \ + yum -y install sudo util-linux lsof && \ + yum -y install postgresql-server postgresql && \ + mkdir /docker-entrypoint-initdb.d && \ + chown postgres:postgres /docker-entrypoint-initdb.d && \ + yum clean all + +COPY gosu-amd64 /usr/local/bin/gosu_amd64 +COPY gosu-arm64 /usr/local/bin/gosu_arm64 + +ENV GOSU_VERSION 1.12 +RUN set -eux; \ + chmod +x /usr/local/bin/gosu_amd64 && \ + chmod +x /usr/local/bin/gosu_arm64 + +VOLUME /var/lib/pgsql/data + +ENV PGDATA /var/lib/pgsql/data +COPY entrypoint.sh /var/lib/pgsql/ +RUN chmod 755 /var/lib/pgsql/entrypoint.sh + +ENTRYPOINT ["/var/lib/pgsql/entrypoint.sh"] +EXPOSE 5432 +CMD [ "postgres" ] diff --git a/postgres/13.3/22.03-lts/entrypoint.sh b/postgres/13.3/22.03-lts/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..2bd9113ae1a08a9d0339586039bb20d02a5cdb4f --- /dev/null +++ b/postgres/13.3/22.03-lts/entrypoint.sh @@ -0,0 +1,362 @@ +#!/usr/bin/env bash +set -Eeo pipefail + +arch=$(case $(uname -m) in i386) echo "386" ;; i686) echo "386" ;; x86_64) echo "amd64";; aarch64)echo "arm64";; esac) +if [ "${arch}" = "amd64" ]; then + GOSU_EXEC=/usr/local/bin/gosu_amd64 +else + GOSU_EXEC=/usr/local/bin/gosu_arm64 +fi +if [ ! -f /usr/local/bin/gosu ]; then + ln -s ${GOSU_EXEC} /usr/local/bin/gosu +fi + +# usage: file_env VAR [DEFAULT] +# ie: file_env 'XYZ_DB_PASSWORD' 'example' +# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of +# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) +file_env() { + local var="$1" + local fileVar="${var}_FILE" + local def="${2:-}" + if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then + echo >&2 "error: both $var and $fileVar are set (but are exclusive)" + exit 1 + fi + local val="$def" + if [ "${!var:-}" ]; then + val="${!var}" + elif [ "${!fileVar:-}" ]; then + val="$(< "${!fileVar}")" + fi + export "$var"="$val" + unset "$fileVar" +} + +# check to see if this file is being run or sourced from another script +_is_sourced() { + [ "${#FUNCNAME[@]}" -ge 2 ] \ + && [ "${FUNCNAME[0]}" = '_is_sourced' ] \ + && [ "${FUNCNAME[1]}" = 'source' ] +} + +# used to create initial postgres directories and if run as root, ensure ownership to the "postgres" user +docker_create_db_directories() { + local user; user="$(id -u)" + + mkdir -p "$PGDATA" + # ignore failure since there are cases where we can't chmod (and PostgreSQL might fail later anyhow - it's picky about permissions of this directory) + chmod 700 "$PGDATA" || : + + # ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289 + mkdir -p /var/run/postgresql || : + chmod 775 /var/run/postgresql || : + + # Create the transaction log directory before initdb is run so the directory is owned by the correct user + if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then + mkdir -p "$POSTGRES_INITDB_WALDIR" + if [ "$user" = '0' ]; then + find "$POSTGRES_INITDB_WALDIR" \! -user postgres -exec chown postgres '{}' + + fi + chmod 700 "$POSTGRES_INITDB_WALDIR" + fi + + # allow the container to be started with `--user` + if [ "$user" = '0' ]; then + find "$PGDATA" \! -user postgres -exec chown postgres '{}' + + find /var/run/postgresql \! -user postgres -exec chown postgres '{}' + + fi +} + +# initialize empty PGDATA directory with new database via 'initdb' +# arguments to `initdb` can be passed via POSTGRES_INITDB_ARGS or as arguments to this function +# `initdb` automatically creates the "postgres", "template0", and "template1" dbnames +# this is also where the database user is created, specified by `POSTGRES_USER` env +docker_init_database_dir() { + # "initdb" is particular about the current user existing in "/etc/passwd", so we use "nss_wrapper" to fake that if necessary + # see https://github.com/docker-library/postgres/pull/253, https://github.com/docker-library/postgres/issues/359, https://cwrap.org/nss_wrapper.html + local uid; uid="$(id -u)" + if ! getent passwd "$uid" &> /dev/null; then + # see if we can find a suitable "libnss_wrapper.so" (https://salsa.debian.org/sssd-team/nss-wrapper/-/commit/b9925a653a54e24d09d9b498a2d913729f7abb15) + local wrapper + for wrapper in {/usr,}/lib{/*,}/libnss_wrapper.so; do + if [ -s "$wrapper" ]; then + NSS_WRAPPER_PASSWD="$(mktemp)" + NSS_WRAPPER_GROUP="$(mktemp)" + export LD_PRELOAD="$wrapper" NSS_WRAPPER_PASSWD NSS_WRAPPER_GROUP + local gid; gid="$(id -g)" + echo "postgres:x:$uid:$gid:PostgreSQL:$PGDATA:/bin/false" > "$NSS_WRAPPER_PASSWD" + echo "postgres:x:$gid:" > "$NSS_WRAPPER_GROUP" + break + fi + done + fi + + if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then + set -- --waldir "$POSTGRES_INITDB_WALDIR" "$@" + fi + + eval 'initdb --username="$POSTGRES_USER" --pwfile=<(echo "$POSTGRES_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"' + + # unset/cleanup "nss_wrapper" bits + if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then + rm -f "$NSS_WRAPPER_PASSWD" "$NSS_WRAPPER_GROUP" + unset LD_PRELOAD NSS_WRAPPER_PASSWD NSS_WRAPPER_GROUP + fi +} + +# print large warning if POSTGRES_PASSWORD is long +# error if both POSTGRES_PASSWORD is empty and POSTGRES_HOST_AUTH_METHOD is not 'trust' +# print large warning if POSTGRES_HOST_AUTH_METHOD is set to 'trust' +# assumes database is not set up, ie: [ -z "$DATABASE_ALREADY_EXISTS" ] +docker_verify_minimum_env() { + # check password first so we can output the warning before postgres + # messes it up + if [ "${#POSTGRES_PASSWORD}" -ge 100 ]; then + cat >&2 <<-'EOWARN' + + WARNING: The supplied POSTGRES_PASSWORD is 100+ characters. + + This will not work if used via PGPASSWORD with "psql". + + https://www.postgresql.org/message-id/flat/E1Rqxp2-0004Qt-PL%40wrigleys.postgresql.org (BUG #6412) + https://github.com/docker-library/postgres/issues/507 + + EOWARN + fi + if [ -z "$POSTGRES_PASSWORD" ] && [ 'trust' != "$POSTGRES_HOST_AUTH_METHOD" ]; then + # The - option suppresses leading tabs but *not* spaces. :) + cat >&2 <<-'EOE' + Error: Database is uninitialized and superuser password is not specified. + You must specify POSTGRES_PASSWORD to a non-empty value for the + superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run". + + You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all + connections without a password. This is *not* recommended. + + See PostgreSQL documentation about "trust": + https://www.postgresql.org/docs/current/auth-trust.html + EOE + exit 1 + fi + if [ 'trust' = "$POSTGRES_HOST_AUTH_METHOD" ]; then + cat >&2 <<-'EOWARN' + ******************************************************************************** + WARNING: POSTGRES_HOST_AUTH_METHOD has been set to "trust". This will allow + anyone with access to the Postgres port to access your database without + a password, even if POSTGRES_PASSWORD is set. See PostgreSQL + documentation about "trust": + https://www.postgresql.org/docs/current/auth-trust.html + In Docker's default configuration, this is effectively any other + container on the same system. + + It is not recommended to use POSTGRES_HOST_AUTH_METHOD=trust. Replace + it with "-e POSTGRES_PASSWORD=password" instead to set a password in + "docker run". + ******************************************************************************** + EOWARN + fi +} + +# usage: docker_process_init_files [file [file [...]]] +# ie: docker_process_init_files /always-initdb.d/* +# process initializer files, based on file extensions and permissions +docker_process_init_files() { + # psql here for backwards compatibility "${psql[@]}" + psql=( docker_process_sql ) + + echo + local f + for f; do + case "$f" in + *.sh) + # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 + # https://github.com/docker-library/postgres/pull/452 + if [ -x "$f" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; + *.sql) echo "$0: running $f"; docker_process_sql -f "$f"; echo ;; + *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | docker_process_sql; echo ;; + *.sql.xz) echo "$0: running $f"; xzcat "$f" | docker_process_sql; echo ;; + *.sql.zst) echo "$0: running $f"; zstd -dc "$f" | docker_process_sql; echo ;; + *) echo "$0: ignoring $f" ;; + esac + echo + done +} + +# Execute sql script, passed via stdin (or -f flag of pqsl) +# usage: docker_process_sql [psql-cli-args] +# ie: docker_process_sql --dbname=mydb <<<'INSERT ...' +# ie: docker_process_sql -f my-file.sql +# ie: docker_process_sql > "$PGDATA/pg_hba.conf" +} + +pg_setup_postgresql_conf() { + { + echo "listen_addresses = '*'" + } >> "$PGDATA/postgresql.conf" +} + + +# start socket-only postgresql server for setting up or running scripts +# all arguments will be passed along as arguments to `postgres` (via pg_ctl) +docker_temp_server_start() { + if [ "$1" = 'postgres' ]; then + shift + fi + + # internal start of server in order to allow setup using psql client + # does not listen on external TCP/IP and waits until start finishes + set -- "$@" -c listen_addresses='' -p "${PGPORT:-5432}" + + PGUSER="${PGUSER:-$POSTGRES_USER}" \ + pg_ctl -D "$PGDATA" \ + -o "$(printf '%q ' "$@")" \ + -w start +} + +# stop postgresql server after done setting up user and running scripts +docker_temp_server_stop() { + PGUSER="${PGUSER:-postgres}" \ + pg_ctl -D "$PGDATA" -m fast -w stop +} + +# check arguments for an option that would cause postgres to stop +# return true if there is one +_pg_want_help() { + local arg + for arg; do + case "$arg" in + # postgres --help | grep 'then exit' + # leaving out -C on purpose since it always fails and is unhelpful: + # postgres: could not access the server configuration file "/var/lib/pgsql/data/postgresql.conf": No such file or directory + -'?'|--help|--describe-config|-V|--version) + return 0 + ;; + esac + done + return 1 +} + +_main() { + # if first arg looks like a flag, assume we want to run postgres server + if [ "${1:0:1}" = '-' ]; then + set -- postgres "$@" + fi + + if [ "$1" = 'postgres' ] && ! _pg_want_help "$@"; then + docker_setup_env + # setup data directories and permissions (when run as root) + docker_create_db_directories + if [ "$(id -u)" = '0' ]; then + # then restart script as postgres user + exec gosu postgres "$BASH_SOURCE" "$@" + fi + + # only run initialization on an empty data directory + if [ -z "$DATABASE_ALREADY_EXISTS" ]; then + docker_verify_minimum_env + + # check dir permissions to reduce likelihood of half-initialized database + ls /docker-entrypoint-initdb.d/ > /dev/null + + docker_init_database_dir + pg_setup_hba_conf "$@" + pg_setup_postgresql_conf + + # PGPASSWORD is required for psql when authentication is required for 'local' connections via pg_hba.conf and is otherwise harmless + # e.g. when '--auth=md5' or '--auth-local=md5' is used in POSTGRES_INITDB_ARGS + export PGPASSWORD="${PGPASSWORD:-$POSTGRES_PASSWORD}" + docker_temp_server_start "$@" + + docker_setup_db + docker_process_init_files /docker-entrypoint-initdb.d/* + + docker_temp_server_stop + unset PGPASSWORD + + echo + echo 'PostgreSQL init process complete; ready for start up.' + echo + else + echo + echo 'PostgreSQL Database directory appears to contain a database; Skipping initialization' + echo + fi + fi + + exec "$@" +} + +if ! _is_sourced; then + _main "$@" +fi diff --git a/postgres/13.3/22.03-lts/gosu-amd64 b/postgres/13.3/22.03-lts/gosu-amd64 new file mode 100644 index 0000000000000000000000000000000000000000..834951f8910b8f4f88d626a05c9c0cdce527f967 Binary files /dev/null and b/postgres/13.3/22.03-lts/gosu-amd64 differ diff --git a/postgres/13.3/22.03-lts/gosu-arm64 b/postgres/13.3/22.03-lts/gosu-arm64 new file mode 100644 index 0000000000000000000000000000000000000000..925e16ed1ff020e522c815ae4b6b8349634ef30a Binary files /dev/null and b/postgres/13.3/22.03-lts/gosu-arm64 differ diff --git a/postgres/README.md b/postgres/README.md new file mode 100644 index 0000000000000000000000000000000000000000..bdfc79c326e984d64c949bc6cfdd3d9738214cd1 --- /dev/null +++ b/postgres/README.md @@ -0,0 +1,43 @@ +# PostgreSQL + +# Quick reference + +- The official openGauss-lite docker image. + +- Maintained by: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative) + +- Where to get help: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative), [openEuler](https://gitee.com/openeuler/community) + +# Build reference + +1. Build images and push: +```shell +docker buildx build -t "openeuler/postgres:$VERSION" --platform linux/amd64,linux/arm64 . --push +``` + +We are using `buildx` in here to generate multi-arch images, see more in [Docker Buildx](https://docs.docker.com/buildx/working-with-buildx/) + +# How to use this image +## start a openGauss instance +```shell +docker run --name my_postgresql -d -e POSTGRES_PASSWORD=PostgreSQL@123 openeuler/postgres:13.3 +``` +The default postgres user and database are created in the entrypoint with initdb. + +## connect database using gsql from os +```shell +docker run --name my_postgresql -d -e POSTGRES_PASSWORD=PostgreSQL@123 -p5433:5432 openeuler/postgres:13.3 +psql -d postgres -U postgres -W 'PostgreSQL@123' -h host_ip -p 5433 +``` + +## persist data to local storage +```shell +docker run --name my_postgresql -d -e POSTGRES_PASSWORD=PostgreSQL@123 -v /postgresql:/var/lib/pgsql/data openeuler/postgres:13.3 +``` + +# Supported tags and respective Dockerfile links + +- 13.3-22.03-lts: postgres v13.3, openEuler 22.03 LTS + +## Operating System +Linux/Unix, ARM64 or x86-64 architecture. diff --git a/python/3.9.9/22.03-lts/Dockerfile b/python/3.9.9/22.03-lts/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0a01e3c4620d55d7f7481063e94e784393dba3ff --- /dev/null +++ b/python/3.9.9/22.03-lts/Dockerfile @@ -0,0 +1,6 @@ +FROM openeuler/openeuler:22.03-lts +MAINTAINER heguofeng +RUN yum -y update \ + && yum -y install python python-pip \ + && yum clean all +CMD [ "python" ] diff --git a/python/README.md b/python/README.md new file mode 100644 index 0000000000000000000000000000000000000000..036f4aab1adcde438412499779b57ad520baa3c7 --- /dev/null +++ b/python/README.md @@ -0,0 +1,30 @@ +# Python + +# Quick reference + +- The official Python docker image. + +- Maintained by: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative) + +- Where to get help: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative), [openEuler](https://gitee.com/openeuler/community) + +# Build reference + +1. Build images and push: +```shell +docker buildx build -t "openeuler/python:$VERSION" --platform linux/amd64,linux/arm64 . --push +``` + +We are using `buildx` in here to generate multi-arch images, see more in [Docker Buildx](https://docs.docker.com/buildx/working-with-buildx/) + +2. Run: +```shell +docker run -d openeuler/python:3.9.9-22.03-lts +``` + +# Supported tags and respective Dockerfile links + +- 3.9.9-22.03-lts: python v3.9.9, openEuler 22.03 LTS + +## Operating System +Linux/Unix, ARM64 or x86-64 architecture. diff --git a/redis/6.2.7/22.03-lts/Dockerfile b/redis/6.2.7/22.03-lts/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d138a78c5f20fb88e173194e3db1b57b00c6043e --- /dev/null +++ b/redis/6.2.7/22.03-lts/Dockerfile @@ -0,0 +1,24 @@ +FROM openeuler/openeuler:22.03-lts +MAINTAINER heguofeng +RUN yum -y update && \ + yum -y install sudo util-linux findutils redis6 && \ + yum clean all + +RUN mkdir /data && chown redis:redis /data +VOLUME /data +WORKDIR /data + +ENV REDIS_VERSION 6.2.7 +ENV GOSU_VERSION 1.12 + +COPY gosu-amd64 /usr/local/bin/gosu_amd64 +COPY gosu-arm64 /usr/local/bin/gosu_arm64 +COPY entrypoint.sh /usr/local/bin/ +RUN chmod 755 /usr/local/bin/entrypoint.sh && \ + chmod 755 /usr/local/bin/gosu_amd64 && \ + chmod 755 /usr/local/bin/gosu_arm64 + +ENTRYPOINT ["entrypoint.sh"] + +EXPOSE 6379 +CMD ["redis-server"] diff --git a/redis/6.2.7/22.03-lts/entrypoint.sh b/redis/6.2.7/22.03-lts/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..4f4c37feda034a46b7d1d04ec06a10f499c82e5a --- /dev/null +++ b/redis/6.2.7/22.03-lts/entrypoint.sh @@ -0,0 +1,34 @@ +#!/bin/sh +set -e + +arch=$(case $(uname -m) in i386) echo "386" ;; i686) echo "386" ;; x86_64) echo "amd64";; aarch64)echo "arm64";; esac) +if [ "${arch}" = "amd64" ]; then + GOSU_EXEC=/usr/local/bin/gosu_amd64 +else + GOSU_EXEC=/usr/local/bin/gosu_arm64 +fi +if [ ! -f /usr/local/bin/gosu ]; then + ln -s ${GOSU_EXEC} /usr/local/bin/gosu +fi + +# first arg is `-f` or `--some-option` +# or first arg is `something.conf` +if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then + set -- redis-server "$@" +fi + +# allow the container to be started with `--user` +if [ "$1" = 'redis-server' -a "$(id -u)" = '0' ]; then + find . \! -user redis -exec chown redis '{}' + + exec gosu redis "$0" "$@" +fi + +# set an appropriate umask (if one isn't set already) +# - https://github.com/docker-library/redis/issues/305 +# - https://github.com/redis/redis/blob/bb875603fb7ff3f9d19aad906bd45d7db98d9a39/utils/systemd-redis_server.service#L37 +um="$(umask)" +if [ "$um" = '0022' ]; then + umask 0077 +fi + +exec "$@" diff --git a/redis/6.2.7/22.03-lts/gosu-amd64 b/redis/6.2.7/22.03-lts/gosu-amd64 new file mode 100644 index 0000000000000000000000000000000000000000..834951f8910b8f4f88d626a05c9c0cdce527f967 Binary files /dev/null and b/redis/6.2.7/22.03-lts/gosu-amd64 differ diff --git a/redis/6.2.7/22.03-lts/gosu-arm64 b/redis/6.2.7/22.03-lts/gosu-arm64 new file mode 100644 index 0000000000000000000000000000000000000000..925e16ed1ff020e522c815ae4b6b8349634ef30a Binary files /dev/null and b/redis/6.2.7/22.03-lts/gosu-arm64 differ diff --git a/redis/README.md b/redis/README.md new file mode 100644 index 0000000000000000000000000000000000000000..ad72235431914d7068adea1cbefaa1be60236322 --- /dev/null +++ b/redis/README.md @@ -0,0 +1,51 @@ +#redis + + +# Quick reference + +- The official redis docker image. + +- Maintained by: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative) + +- Where to get help: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative), [openEuler](https://gitee.com/openeuler/community) + +# Build reference + +1. Build images and push: +```shell +docker buildx build -t "openeuler/redis:$VERSION" --platform linux/amd64,linux/arm64 . --push +``` + +We are using `buildx` in here to generate multi-arch images, see more in [Docker Buildx](https://docs.docker.com/buildx/working-with-buildx/) + +# How to use this image +## start a redis instance +```shell +docker run --name my-redis -d openeuler/redis:6.2.7 +``` + +## Start with persistent storage +```shell +docker run --name my-redis -d openeuler/redis:6.2.7 redis-server --save 60 1 --loglevel warning +``` +As shows above, this will save a snapshot of the DB every 60 seconds if at least 1 write operation was performed. + +## connect to a redis instance +Connect to a local redis instance using loopback address +```shell +docker run --name my-redis -d -p 6379:6379 openeuler/redis:6.2.7 +redis-cli -h 127.0.0.1 -p 6379 +``` + +If you want connect the redis instance using hostip, you should connect to the instance using loopback, +and then configure as belows +```shell +config set protected-mode no +``` + +# Supported tags and respective Dockerfile links + +- 6.2.7-22.03-lts: redis v6.2.7, openEuler 22.03 LTS + +## Operating System +Linux/Unix, ARM64 or x86-64 architecture.