Update this page? for POSTgres?

File: samples/postgresql_service.md
Keep getting this error
 => CACHED [1/7] FROM docker.io/library/ubuntu:16.04@sha256:0f71fa8d4d2d4292c3c617fda2b36f6dabe5c8b6e3  0.0s
 => ERROR [2/7] RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFC  18.7s
------
 > [2/7] RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8:
#8 0.295 Executing: /tmp/tmp.wTAfZdb86H/gpg.1.sh --keyserver
#8 0.295 hkp://p80.pool.sks-keyservers.net:80
#8 0.295 --recv-keys
#8 0.295 B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
#8 0.297 gpg: requesting key ACCC4CF8 from hkp server p80.pool.sks-keyservers.net
#8 18.72 ?: p80.pool.sks-keyservers.net: Host not found
#8 18.72 gpgkeys: HTTP fetch error 7: couldn't connect: Success
#8 18.72 gpg: no valid OpenPGP data found.
#8 18.72 gpg: Total number processed: 0
#8 18.72 gpg: keyserver communications error: keyserver unreachable
#8 18.72 gpg: keyserver communications error: public key not found
#8 18.72 gpg: keyserver receive failed: public key not found
------
executor failed running [/bin/sh -c apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys
B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8]: exit code: 2

got same issue

@Robert969696  Try this Dockerfile
`#
NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"

PLEASE DO NOT EDIT IT DIRECTLY.

FROM debian:bullseye-slim
RUN set -ex;
if ! command -v gpg > /dev/null; then
apt-get update;
apt-get install -y --no-install-recommends
gnupg
dirmngr
;
rm -rf /var/lib/apt/lists/*;
fi
explicitly set user/group IDs
RUN set -eux;
groupadd -r postgres --gid=999; \
https://salsa.debian.org/postgresql/postgresql-common/blob/997d842ee744687d99a2b2d95c1083a2615c79e8/debian/postgresql-common.postinst#L32-35
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \

also create the postgres user's home directory with appropriate permissions
see https://github.com/docker-library/postgres/issues/274
mkdir -p /var/lib/postgresql; \
chown -R postgres:postgres /var/lib/postgresql

grab gosu for easy step-down from root
https://github.com/tianon/gosu/releases
ENV GOSU_VERSION 1.14
RUN set -eux;
savedAptMark="$(apt-mark showmanual)";
apt-get update;
apt-get install -y --no-install-recommends ca-certificates wget;
rm -rf /var/lib/apt/lists/;
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')";
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch";
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc";
export GNUPGHOME="$(mktemp -d)";
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4;
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu;
gpgconf --kill all;
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc;
apt-mark auto '.' > /dev/null;
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark > /dev/null;
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false;
chmod +x /usr/local/bin/gosu;
gosu --version;
gosu nobody true
make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
RUN set -eux;
if [ -f /etc/dpkg/dpkg.cfg.d/docker ]; then \
if this file exists, we're likely in "debian:xxx-slim", and locales are thus being excluded so we need to remove that exclusion (since we need locales)
	grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker; \
	sed -ri '/\/usr\/share\/locale/d' /etc/dpkg/dpkg.cfg.d/docker; \
	! grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker; \
fi; \
apt-get update; apt-get install -y --no-install-recommends locales; rm -rf /var/lib/apt/lists/*; \
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

ENV LANG en_US.utf8
RUN set -eux;
apt-get update;
apt-get install -y --no-install-recommends \
install "nss_wrapper" in case we need to fake "/etc/passwd" and "/etc/group" (especially for OpenShift)
https://github.com/docker-library/postgres/issues/359
https://cwrap.org/nss_wrapper.html
	libnss-wrapper \

install "xz-utils" for .sql.xz docker-entrypoint-initdb.d files
	xz-utils \
; \
rm -rf /var/lib/apt/lists/*

RUN mkdir /docker-entrypoint-initdb.d
RUN set -ex; \
pub   4096R/ACCC4CF8 2011-10-13 [expires: 2019-07-02]
Key fingerprint = B97B 0AFC AA1A 47F0 44F2  44A0 7FCC 7D46 ACCC 4CF8
uid                  PostgreSQL Debian Repository
key='B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8'; \
export GNUPGHOME="$(mktemp -d)"; \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key"; \
gpg --batch --export "$key" > /etc/apt/trusted.gpg.d/postgres.gpg; \
command -v gpgconf > /dev/null && gpgconf --kill all; \
rm -rf "$GNUPGHOME"; \
apt-key list

ENV PG_MAJOR 14
ENV PATH $PATH:/usr/lib/postgresql/$PG_MAJOR/bin
ENV PG_VERSION 14.1-1.pgdg110+1
RUN set -ex;
\
see note below about "*.pyc" files
export PYTHONDONTWRITEBYTECODE=1; \
\
dpkgArch="$(dpkg --print-architecture)"; \
case "$dpkgArch" in \
	amd64 | arm64 | ppc64el) \

arches officialy built by upstream
		echo "deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main $PG_MAJOR" > /etc/apt/sources.list.d/pgdg.list; \
		apt-get update; \
		;; \
	*) \

we're on an architecture upstream doesn't officially build for
let's build binaries from their published source packages
		echo "deb-src http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main $PG_MAJOR" > /etc/apt/sources.list.d/pgdg.list; \
		\
		tempDir="$(mktemp -d)"; \
		cd "$tempDir"; \
		\
		savedAptMark="$(apt-mark showmanual)"; \
		\

build .deb files from upstream's source packages (which are verified by apt-get)
		apt-get update; \
		apt-get build-dep -y \
			postgresql-common pgdg-keyring \
			"postgresql-$PG_MAJOR=$PG_VERSION" \
		; \
		DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" \
			apt-get source --compile \
				postgresql-common pgdg-keyring \
				"postgresql-$PG_MAJOR=$PG_VERSION" \
		; \

we don't remove APT lists here because they get re-downloaded and removed later
		\

reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
(which is done after we install the built packages so we don't have to redownload any overlapping dependencies)
		apt-mark showmanual | xargs apt-mark auto > /dev/null; \
		apt-mark manual $savedAptMark; \
		\

create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be)
		ls -lAFh; \
		dpkg-scanpackages . > Packages; \
		grep '^Package: ' Packages; \
		echo "deb [ trusted=yes ] file://$tempDir ./" > /etc/apt/sources.list.d/temp.list; \

work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes")
Could not open file /var/lib/apt/lists/partial/tmp_tmp.ODWljpQfkE._Packages - open (13: Permission denied)
...
E: Failed to fetch store:/var/lib/apt/lists/partial/tmp_tmp.ODWljpQfkE._Packages  Could not open file /var/lib/apt/lists/partial/tmp_tmp.ODWljpQfkE._Packages - open (13: Permission denied)
		apt-get -o Acquire::GzipIndexes=false update; \
		;; \
esac; \
\
apt-get install -y --no-install-recommends postgresql-common; \
sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf; \
apt-get install -y --no-install-recommends \
	"postgresql-$PG_MAJOR=$PG_VERSION" \
; \
\
rm -rf /var/lib/apt/lists/*; \
\
if [ -n "$tempDir" ]; then \

if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
	apt-get purge -y --auto-remove; \
	rm -rf "$tempDir" /etc/apt/sources.list.d/temp.list; \
fi; \
\

some of the steps above generate a lot of "*.pyc" files (and setting "PYTHONDONTWRITEBYTECODE" beforehand doesn't propagate properly for some reason), so we clean them up manually (as long as they aren't owned by a package)
find /usr -name '*.pyc' -type f -exec bash -c 'for pyc; do dpkg -S "$pyc" &> /dev/null || rm -vf "$pyc"; done' -- '{}' +; \
\
postgres --version

make the sample config easier to munge (and "correct by default")
RUN set -eux;
dpkg-divert --add --rename --divert "/usr/share/postgresql/postgresql.conf.sample.dpkg" "/usr/share/postgresql/$PG_MAJOR/postgresql.conf.sample";
cp -v /usr/share/postgresql/postgresql.conf.sample.dpkg /usr/share/postgresql/postgresql.conf.sample;
ln -sv ../postgresql.conf.sample "/usr/share/postgresql/$PG_MAJOR/";
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.!\1 = ''!" /usr/share/postgresql/postgresql.conf.sample;
grep -F "listen_addresses = '*'" /usr/share/postgresql/postgresql.conf.sample
RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod 2777 /var/run/postgresql
ENV PGDATA /var/lib/postgresql/data
this 777 will be replaced by 700 at runtime (allows semi-arbitrary "--user" values)
RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA"
VOLUME /var/lib/postgresql/data
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
We set the default STOPSIGNAL to SIGINT, which corresponds to what PostgreSQL
calls "Fast Shutdown mode" wherein new connections are disallowed and any
in-progress transactions are aborted, allowing PostgreSQL to stop cleanly and
flush tables to disk, which is the best compromise available to avoid data
corruption.

Users who know their applications do not keep open long-lived idle connections
may way to use a value of SIGTERM instead, which corresponds to "Smart
Shutdown mode" in which any existing sessions are allowed to finish and the
server stops when all sessions are terminated.

See https://www.postgresql.org/docs/12/server-shutdown.html for more details
about available PostgreSQL server shutdown signals.

See also https://www.postgresql.org/docs/12/server-start.html for further
justification of this as the default value, namely that the example (and
shipped) systemd service files use the "Fast Shutdown mode" for service
termination.

STOPSIGNAL SIGINT

An additional setting that is recommended for all users regardless of this
value is the runtime "--stop-timeout" (or your orchestrator/runtime's
equivalent) for controlling how long to wait between sending the defined
STOPSIGNAL and sending SIGKILL (which is likely to cause data corruption).

The default in most runtimes (such as Docker) is 10 seconds, and the
documentation at https://www.postgresql.org/docs/12/server-start.html notes
that even 90 seconds may not be long enough in many instances.
EXPOSE 5432
CMD ["postgres"]`

@Robert969696  try this repo it worked for me https://github.com/docker-library/postgres

Thanks for sharing the issue. Closing as this content will soon be removed from the docs.
Please see https://github.com/docker/awesome-compose for samples.


library/aws/Aws/S3/Enum/CannedAcl.php failed to open stream

reported here

PHP Warning:  require(/Users//S3StaticTest/wp-content/plugins/static-html-output-plugin/library/aws/Aws/S3/Enum/CannedAcl.php): failed to open stream: No such file or directory in /Users//S3StaticTest/wp-content/plugins/static-html-output-plugin/library/aws/aws-autoloader.php on line 1349

or

PHP Fatal error: require(): Failed opening required ‘/mycode/blog/wp-content/plugins/static-html-output-plugin/library/aws/Aws/S3/Enum/CannedAcl.php’ (include_path=’.:/usr/share/php:/usr/share/pear’) in /mycode/blog/wp-content/plugins/static-html-output-plugin/library/aws/aws-autoloader.php on line 1349

I'm seeing this too, works fine on 1.8

Should I just go to 1.8 or is there a work around?

Is there a workaround for this bug?

@leonstafford I'm wondering if this is only a bug in 1.9 because of the difference between what wordpress delivers via gui vs what you have in github.  Github version seems to not have this missing file issue.


TEST: feat(docker): support arm64 for image

This is a pull request to check the behavior when merging into the master branch.

publishに失敗したのとタグつけ忘れてたので別プルリクエストでリトライ😇
https://github.com/korosuke613/secretlint/actions/runs/2089568057/attempts/1


Just a question

HI! This system is amazing and Im having a great time using it, im wondering if theres a way I can change this dynamically, for example the theme, if I wanted to change the theme in any conversation to dark  when its night time, how would I accomplish that?

Hi, I'm glad you're enjoying it! Theme swapping is supported, and it's quite easy to implement. There's a video showcasing it here. You just need to create a theme asset, assign it to the theme repo, which allows you to either change it through conversations using actions, or with the "theme" tag on a given conversation.
You can see examples in the ExampleScene->Conversations->DialogueFiles->TestingConversation. The conversation with the Id of 1 starts with the theme set to default, then changes it using an action

That worked! I didn't even notice there was a changetheme variable in the controller, my bad. Thanks for your help! And also, do you plan to update the system more? And if so what are you planning to add?

Hi, I just discovered a bug that makes me unable to trigger different conversations with other npcs, then I register the bools I do it through code and initialize them on a start method like this: ```
if (draxFirstConversation)
{
VariableRepo.Instance.Register("draxFirstConversation", true);
}
else
{
VariableRepo.Instance.Register("draxFirstConversation", false);
    }

the issue is that all npcs get overwritten with the conversation that the boolean defined true, why isnt the conversation being loaded based on the actual file that already is getting passed in?

Hi, I'm not quite sure I follow. You have multiple conversations, loaded into the conversation repo, but when you register the variable VariableRepo.Instance.Register("draxFirstConversation", draxFirstConversation);, those conversations get overridden?

Exactly, when I register through code all conversations just lead to that conversation that was registered

Thanks for bringing it to my attention, I'll investigate it later today. I suspect it's a pretty easy fix. Would you mind giving me your conversation JSON files so I can test it with your starting conditions? Feel free to take out all the game's dialogue.

Appreciate it! https://easyupload.io/gfygao here you go

I've had a quick look at the files you've sent, and it's behaving as expected on my end. I think the issue is that in both JSON files you have a conversation node, with the id of 18, that's the same. So when the variable draxFirstConversation is changed both conversations say the same thing. I've modified node 18 to show the "Drax" and "Old Man In Cave" in these files, and everything appears to be working normally.

Hey, sorry, was my error, forgot to update you! Appreciate the attention as well, was wondering of theres a way to cast variables in the json, for example <sendmessage=DialogueController>RegisterVariableToRepo(convo1, true).
Thanks!


Are linkopts propagated from copts and/or deps ?

The linker complains about not finding -lpthread, while I didn't add this flag to linkopts.
I've checked the executed command, and in fact there is extra flags on it -lz  -lpthread ....
Where did they came from ? Is there a workaround for this ?
More details
BUILD file
cc_binary(
    name = "libfoo.so",
    srcs = glob([
         "jni/**/*.cc",
         "jni/**/*.h",
    ]),
    copts = [ "-fexceptions", "-DEIGEN_AVOID_STL_ARRAY",
              "-mfpu=neon", "-std=c++11",
              "-DMIN_LOG_LEVEL=0", "-DTF_LEAN_BINARY",
              "-O2", ],
    linkopts = [
        "-llog",
        "-lm",
    ],
    linkshared = 1,
    deps = [
        "@org_tensorflow//tensorflow/core:android_tensorflow_lib",
        "@boringssl//:crypto",
    ],
)

Command
bazel build -c opt //:libfoo.so --crosstool_top=//external:android/crosstool --cpu=armeabi-v7a --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --verbose_failures --sandbox_debug --strategy=CppLink=standalone
Full error
...
  external/bazel_tools/tools/cpp/link_dynamic_library.sh no ignored ignored ignored external/androidndk/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc -shared -o bazel-out/arm-linux-androideabi-4.9-v7a-gnu-libstdcpp-opt/bin/libfoo.so -Wl,-whole-archive bazel-out/arm-linux-androideabi-4.9-v7a-gnu-libstdcpp-opt/bin/external/org_tensorflow/tensorflow/core/libandroid_tensorflow_lib.lo -Wl,-no-whole-archive -Wl,-whole-archive bazel-out/arm-linux-androideabi-4.9-v7a-gnu-libstdcpp-opt/bin/external/org_tensorflow/tensorflow/core/kernels/libandroid_tensorflow_kernels.lo -Wl,-no-whole-archive -Wl,-whole-archive bazel-out/arm-linux-androideabi-4.9-v7a-gnu-libstdcpp-opt/bin/external/org_tensorflow/tensorflow/core/libandroid_tensorflow_lib_lite.lo -Wl,-no-whole-archive -Wl,-whole-archive bazel-out/arm-linux-androideabi-4.9-v7a-gnu-libstdcpp-opt/bin/external/org_tensorflow/tensorflow/core/libprotos_all_cc.a -Wl,-no-whole-archive -Wl,-whole-archive bazel-out/arm-linux-androideabi-4.9-v7a-gnu-libstdcpp-opt/bin/external/protobuf/libprotobuf.a -Wl,-no-whole-archive -Wl,-whole-archive bazel-out/arm-linux-androideabi-4.9-v7a-gnu-libstdcpp-opt/bin/external/protobuf/libprotobuf_lite.a -Wl,-no-whole-archive -Wl,-whole-archive bazel-out/arm-linux-androideabi-4.9-v7a-gnu-libstdcpp-opt/bin/external/boringssl/libcrypto.a -Wl,-no-whole-archive external/androidndk/ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_static.a external/androidndk/ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libsupc++.a -llog -lm -lz -lpthread -static-libgcc -no-canonical-prefixes '-march=armv7-a' -Wl,--fix-cortex-a8 '--sysroot=external/androidndk/ndk/platforms/android-21/arch-arm'): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
external/androidndk/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lpthread
collect2: error: ld returned 1 exit status
Target //:libfoo.so failed to build

$ cd tensorflow
$ git log -1
commit ac352bc807410c8a863d0b95202cceeb62ed0f10
Author: gunan<EMAIL_ADDRESS>Date:   Sun Feb 5 22:19:11 2017 -0800

    Simplify cuDNN library handling in configure script. (#7269)

    cuda_configure.bzl now handles the more complicated operations.

@jart Have you seen this before?

Since copts and linkopts are viral and propagate to dependencies, -lpthread is most likely being inherited from @boringssl//:crypto. See: https://github.com/google/boringssl/blob/bbcaa15b0647816b9a1a9b9e0d209cd6712f0105/BUILD#L91
If linking against BoringSSL for an Android build is genuinely a good thing to do, then this could be a bug. Hey @petewarden what's the correct way to get SSL functionality for Android code? Should our friend be using a different library?
Unrelated suggestions:

name = "libfoo.so",

Just name it "foo" because when Bazel builds this, it will prefix lib and append .so by default.

copts = [ "-fexceptions", "-DEIGEN_AVOID_STL_ARRAY",
"-mfpu=neon", "-std=c++11",
"-DMIN_LOG_LEVEL=0", "-DTF_LEAN_BINARY",
"-O2", ],

Many of these flags might already be inherited from the @org_tensorflow//tensorflow/core:android_tensorflow_lib dependency.
The -O2 (or maybe -O3) flag is set by default when you say bazel build -c opt.
Bazel should already pass flags like -std=c++11 by default.
Another thing to note is that bazel build -s //blah is good for troubleshooting.

@jart Thank you for your answer.
I think a similar question is discussed here. but I don't understand proposed solution, can you help me ?

Just name it "foo" because when Bazel builds this, it will prefix lib and append .so by default.

BUILD:40:18: in linkshared attribute of cc_binary rule //:foo: 'linkshared' used in non-shared library.

Many of these flags might already be inherited from the @org_tensorflow//tensorflow/core:android_tensorflow_lib dependency.

You are right, only -std=c++11 is required here.

@riless @jart
-lpthread is not necessary or possible on Android, so it sounds like the solution would be to add another condition for the select statement as in the linked commit https://github.com/google/protobuf/pull/1386:
    linkopts = select({
        ":mac_x86_64": [],
        ":android": [],
        "//conditions:default": ["-lpthread"],
    }),

which would necessitate adding a config setting like so:
config_setting(
    name = "android",
    values = {
        "crosstool_top": "//external:android/crosstool",
    },
    visibility = ["//visibility:public"],
)

The only other workaround I know of that doesn't require editing the other repository is to create a dummy libpthread.so target, but that's pretty hacky.

I'd like to go with the dummy libpthread.so target solution.
I don't know how to do this. I've tried to add a target like this.
cc_library(
    name = "pthread",
    srcs = ["third_party/empty.cc"],
    visibility = ["//visibility:public"],
    linkstatic = 1
)

And added it to deps of libfoo.so
cc_binary(
    name = "libqscamera.so",
   ...
   deps = [
        "pthread",
        ...
  ]
)

but I still have the cannot find -lpthread error.

@riless See https://github.com/tensorflow/tensorflow/commit/cd53f3c3302c9312c1840389a9988a879b8b9dd5#diff-06b90d704990e9b4f5adadb18c837b64

@andrewharp  it works now, thank you.
I'll still go with this solution as I want boringssl to be downloaded on build.