2021/01,江端さんの忘備録

年を取ると、周り(世間)が見えてこなくなりますが、見えてくることもあります。

As we get older, we lose sight of our surroundings (the world), but we can also see things.

その一つに、

One of them is,

「出来の良い若者には、普通以上の負荷を与えてみたくなる」

"It's tempting to give a well-rounded young persons more than they can handle."

があります。

私が繰り出す厳しい質問に対して、窮することなく、あるいは、窮しながら対応する若者は、

For young engineers who responded to my tough questions without hesitation, or with hesitation, I want to get somethings greedy.

―― 叩けば、もっと力(能力)を引き出せるかもしれない

"If I hit her/him, I might be able to get more their power (ability)"

と、スケベ心がでてきます。

で、「叩く」。

So I hit them.

そして、若者は、程なく潰れ、病んで、退社してしまいます。

And, they will soon be crushed, sick, and leave the company.

-----

『なるほど、若い頃の私が、叩か続けたのは、私が、あまりにも優秀すぎたからだ』

"I see, the reason I kept getting beaten when I was younger was because I was too good"

と、今、気がつきました。

I have just noticed that now.

しかし、一方、私が、潰れてもおらず、病んでもおらず、退社してもいないということは ――

However, I, on the other hand, haven't gone under, haven't gotten sick, haven't left the company--

『そう(優秀すぎる)ということでは、なかった?』

"Was I not too good?"

と、再帰的な思考に陥いっております。

I'm falling into recursive thinking.

-----

ともあれ ――

Anyway,

我々シニアは「スケベ心」を捨てる勇気が必要です。

We seniors need to have the courage to give up our "greed"

優れた若い才能を見ると、手を出したくなるのは分かるのですが ――

I can understand that it's tempting to reach out when we see outstanding young talent, but,

彼らの才能を『放置する勇気』が、今、問われていると思います。

I think the courage to 'leave their talent alone' is what we have to have.

2021/01,江端さんの忘備録

年末に、奥歯を2本抜きました。

At the end of the year, I had two of my back teeth extracted.

歯の根本が膿んでいるらしく、随分長い間、定期的に痛めつけられてきました。

It seems that the root of my tooth is infected and has been hurting me regularly for a very long time.

あんまりにも軽く『2本、抜いてしまいますか?』と軽く言われたこともあったのですが、

One of the reasons why I was told so lightly, "Do you want to take out two of them?

『鎮痛剤も効果のない痛みを抱えたまま、年末年始を過ごさなければならない』と思うと、ゾっとしました。

The main reason was that I was horrified at the thought of having to spend the New Year's holidays with pain that no painkillers would help.

-----

私の人生の基本ポリシーは「苦痛回避」の一択です。

My basic policy in life is one of "pain avoidance".

「快楽」はなくてもいいです。「苦労」も、自分が選んだ苦労なら、受け入れます。

I don't need "pleasure". I accept hardship if it is my choice.

むしろ「苦労」は、気がつかずに自分で拾ってしまう方です。

Rather, I am the one who picks up "hardships" on my own, without even realizing it.

「不当」や「不快」は嫌いですが、これは「反撃」「報復」「殲滅」という手段で、きっちりとケリをつけます。

I don't like "injustice" or "unpleasantness," but I will deal with this by means of "retaliation," "counterattack," and "annihilation.

しかし、「苦痛」だけは、闘うことができません。これは常に「負け」一択です。

However, pain is the only thing that cannot be fought. This is always a "lose" choice.

私は、歯科であれ、内科であれ、外科であれ、そして、精神科であれ、とっとと、病院やクリニックに行き、処方箋を貰って、薬局に走ります(市販のクスリなんぞ、当てにしていません)。

Whether it's dental, medical, surgical, or psychiatric, I go to the hospital or clinic, get a prescription, and run to the pharmacy (I don't rely on over-the-counter drugs).

-----

どうやら、私の人生は「歯を失い始める」フェーズに突入したようです。

Apparently, my life has entered the "start losing teeth" phase.

そもそも、私の年齢は、すでに、太平洋戦争時(75年前)の平均年齢を超えております。

To begin with, my age has already surpassed the average age at the time of the Pacific War (75 years ago).

人間は、100年間程度では進化しません(10万年くらいは必要)ので、私が、今、生きていられるのは、医療やクスリや衛生教育のおかげです。

Humans don't evolve in about 100 years (it takes about 100,000 years), so I am alive today because of medicine, drugs, and hygiene education.

ならば ――

Then...,

『歯の1本や2本くらい、なんだと言うのだ』

"What's a tooth or two matter?"

と、思った5分後には、抜かれた2本の歯を、自分の目で見ていました。

Five minutes later, I was looking at the two teeth that had been pulled out with my own eyes.

-----

私の父は、入れ歯が破損した後、新しい入れ歯との相性が悪く、食欲が減退し、体力を失い、死に至りました。

After my father's dentures were damaged, he lost his appetite, his strength, and his death due to incompatibility with his new dentures.

私の場合も、私を殺しに来るのは、多分「歯」だろうな、と腹を括っています。

In my case, too, I'm gutted that it will probably be "teeth" that will come to kill me.

2021/01,江端さんの忘備録

今、我が国のお隣の半島の国と、その半島の大陸の国が、「キムチ本家争い」で加熱しているそうです。

It is said that the country on the peninsula next to our country and the country on the continent of the peninsula are now heating up in the "Birthplace of kimchi".

民間のレベルを超えて、マスコミや、政府の一部も巻き込んでいるようです。

It seems to go beyond the private level and involves the media and even parts of the government.

私は、これを「大人気ない」とは思っていません。

I do not consider this to be "childish".

食文化は、文化の中でも、もっとも国民感情と強く繋っているものだからです。

Food culture is one of the most important aspects of culture, because it is the one that is most strongly connected to national sentiment.

-----

江端:「キムチについては、我が国発祥ではないことは明らかだから、我が国としては完全に傍観者でいいけどね」

Ebata: "As for kimchi, it's clear that it didn't originate in our country, so as for our country, we're completely bystander"

嫁さん:「でも、もし『"蕎麦"が中国発祥』と言われたら、我が国は許さないだろうね」

Wife: "But if someone says 'Soba' originated in China, our country will not forgive it".

江端:「そうだなぁ、尖閣諸島等の領土問題とバーターとできるかどうか、ギリギリの線だな」

Ebata: "Well, it's a fine line between the Senkaku Islands and other territorial issues, and the terms of the deal"

嫁さん:「でも、『"寿司"が中国発祥』と言われたら・・・」

Wife: "But if they tell us that 'sushi' originated in China..."

江端:「その場合、もう、取り引きできる「モノ」はないな。

Ebata:"In that case, there's no more "stuff" to deal with.

『よろしい。ならば戦争だ』

"Very well. Then it's war"

我が国から宣戦布告しても、国民の民意は得られるだろう、と思う」

I believe that a declaration of war from our country would meet with the public's approval"

憲法違反ですが。

It's against the Constitution, though.

2021/01,江端さんの忘備録

私は、3年くらい前から、私のプログラムの導師であるところのSさんから「"Go言語"こそが、江端さんが必要としているものです」と言われ続けていました。

For about three years now, my program guru, Mr. S, has been telling me that "Go language" is what Mr. Ebata needs.

しかし、私は、なかなか使用に踏み切れませんでした。

However, I was not able to start using it.

その理由を、建前で言えば「時間がない」で、本音で言えば「新しいことを覚えるのは辛い」です。

The reason for this, on the face of it, is "I don't have the time," and the real reason is "It's hard to learn new things.

しかし、今は、戦後最大級の国難「コロナ禍」による在宅勤務。

But now, I am working at home due to the "Corona disaster," one of the biggest national disasters of the postwar era.

―― この機会を逃したら、はっきりいって『バカ』

"If I miss this opportunity, I are clearly a 'fool'"

と、後になって、「自分で、自分を責めることになりそう」なので、今、一生懸命勉強しています。

I'm afraid that later I'll blame myself for what I've done, so I'm studying hard now.

-----

ところで、私がこれまで愛用してきたC/C++という言語は、コンピュータアーキテクチャにベタベタの「超低級言語」です。

By the way, the language I have been using, C/C++, is a "very low-level language" that is closely related to computer architecture.

ですので、超高速で、汎用性が高いです。

So, it is super fast and versatile.

その代わり、その言語表記の「愛想の悪さ」においては、他の言語の追従を許しません。

Instead, it is unrivaled in the "unfriendliness" of its language notation.

C/C++は、コンピュータ(正確に言うとUNIX OS)と同時に生まれた1970年ごろに生まれたロートル言語ですので、最新のWeb技術なんぞには、全く役に立たないといってもよいです。

C/C++ was born around 1970, at the same time as the computer (UNIX OS, to be precise), so it is O.K. to say that it is completely useless for the latest web technologies.

それでも、殆んどのコンピュータシステムのプラットフォーム、特に組み込み系マイコンが、C/C++でプログラミングされているのは事実です。

Still, it is a fact that almost all computer system platforms, especially embedded microcontrollers, are programmed in C/C++.

それはさておき。

Aside from that.

-----

最近になって、やっと"Go言語"の凄さが分かってきました。

Recently, I have finally come to understand the greatness of the "Go language".

「私の作ったシミュレータで、10万人分のスレッド(化したオブジェクト)が最後まで動き続けた」という事実に、感動しています。

I was impressed by the fact that 100,000 threads (objects) kept running until the end in my simulator.

『7000万以上のスレッドが動く』ということは、話で聞いていましたが、「聞く」のと「実際に自分で動かす」のでは、やはり違います。

I had heard that "more than 70 million threads are running", but there is a difference between hearing about it and actually running it by myself.

もしかしたら、日本国民全員のエージェントとした、「コロナ感染シミュレータ」が作れるかもしれません ―― 私の自宅のパソコンごときで。

Maybe I can make a "corona infection simulator" with all Japanese citizens as agents -- on my home computer.

-----

西浦先生のような統計的なアプローチに、私の考えているようなエージェントアプローチが加われば、きっと役に立つと思うんです。

I think it would be useful if the agent approach, which is what I am thinking of, is added to the statistical approach of Dr. Nishiura's.

ただ、このようなエージェントアプローチは、国民全員分のペルソナと環境を設定しなければなりませんので、めちゃくちゃ時間がかかることも明かです。

However, it is also clear that this kind of agent approach is insanely time-consuming because you have to set up personas and environments for the entire population.

まあ、もしできるとしても、完成は10年後くらいでしょうか ―― 10年後に、この災厄がどうなっているかは分かりませんが。

Well, if I can do it, it will be completed in about 10 years -- I don't know what this disaster will be going in 10 years.

2021/01,未分類,江端さんの技術メモ

この問題、

Step 4/7 : WORKDIR /go/hitachi_ride_hailing_go
---> Using cache
---> 62e20b49fae8
Step 5/7 : COPY . .
ERROR: Service 'app' failed to build: Error processing tar file(exit status 1):write /go/xxxxx_ride_hailing_go/static/fonts/Noto Sans Regular/12800-13055.pbf : no space left on device

は、

ディスクスペースを開けるのに"docker system prune"は便利だが、濫用しないこと。docker-compose buildが再び上手く動くという保障はないぞ

で潰した。

しかし、

go: finding github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f
go: finding github.com/tidwall/match v1.0.1
go: error loading module requirements
ERROR: Service 'app' failed to build: The command '/bin/sh -c apk add --no-cache  git g++ curl ? && go mod download ? && GOOS=linux GOARCH=amd64 go build cmd/server/main.go ? && curl -L https://github.com/golang-migrate/migrate/releases/download/v4.13.0/migrate.linux-amd64.tar.gz | tar xvz ? && mv migrate.linux-amd64 /usr/local/bin/migrate' returned a non-zero code: 1

が、どうしても取れない。(全部のコマンドをバラバラにして実行する、までした)

何時間も格闘しているうちに、同じディレクトリにある、go.modの記載内容ではないか、と疑い始めたが、

module codes.xxxxx.co.jp/xxxxx/xxxxxx_ride_hailing_go
go 1.12
require (
        github.com/dgrijalva/jwt-go v3.2.0+incompatible
        github.com/go-chi/chi v4.0.2+incompatible
        github.com/go-chi/jwtauth v4.0.2+incompatible
        github.com/gomodule/redigo v2.0.0+incompatible
        github.com/gorilla/websocket v1.4.0
        github.com/jmoiron/sqlx v1.2.0
        github.com/kawasin73/htask v0.4.1
        github.com/lib/pq v1.1.1
        github.com/rs/xid v1.2.1
        github.com/tidwall/boxtree v0.0.0-20180928224827-327de8d774d7 // indirect
        github.com/tidwall/geojson v1.1.3
        github.com/tidwall/gjson v1.2.1
        github.com/tidwall/match v1.0.1 // indirect
        github.com/tidwall/pretty v0.0.0-20190325153808-1166b9ac2b65 // indirect
        github.com/tidwall/sjson v1.0.4 // indirect
        github.com/twpayne/go-geom v1.0.4
        github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
        github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
        github.com/xeipuuv/gojsonschema v1.1.0
        github.com/xeonx/geodesic v0.0.0-20150531212225-499ffb552e21
        github.com/xeonx/geographic v0.0.0-20150531172044-7bc7968bc5f9
        golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f
        gopkg.in/guregu/null.v3 v3.4.0
)

の中のどれが原因か(それも1つとは限らない)をどうやって見つければいいのか、分からない。

で、さっき、なんだか分からない内に、以下の操作をしてしまったのだけど

ubuntu@ip-57:~/codes/hailing_go/docker/app$ go mod init m
go: creating new go.mod: module m

を見ているうちに、同じディレクトリにm.modというファイルができていることに気がついた。

その中身はこんな風になっていた。

go 1.13
require (
     github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
     github.com/go-chi/jwtauth v4.0.4+incompatible // indirect
)
先程のリストと比較してみたら、
github.com/go-chi/jwtauth v4.0.2+incompatible
github.com/go-chi/jwtauth v4.0.4+incompatible // indirect
が違っていたので、この部分だけを変更して、再度 docker-compose buildを実行してみた。
go: finding github.com/twpayne/go-polyline v1.0.0
go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: finding golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
go: finding golang.org/x/text v0.3.0
go: finding gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0
 % Total % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100  652 100  652 0  0  2069 0 --:--:-- --:--:-- --:--:-- ?2063
0 16.1M  0  0 0  0  0               0 --:--:-- ?0:00:01 --:--:-- ? ? 0./migrate.linux-amd64
100 16.1M 100 16.1M 0  0 3974k 0 0:00:04 0:00:04 --:--:-- 5426k
Removing intermediate container 35c328df0ab6
---> e8cf5804a190
Successfully built e8cf5804a190
Successfully tagged xxxxxx_ride_hailing_go_app:latest
やっと通ったー、長かったー
ほとんどラッキーだけでdocker-compose buildに成功したー
Go moduleは、勝手にバージョン上げるんじゃねーーー
以上

2021/01,江端さんの忘備録

2階の自分の部屋でDockerのポーティングに四苦八苦しているところに、1階のリビングの長女から電話がかかってきました。

While I was struggling with porting Docker in my room on the second floor, I received a call from my senior daughter in the living room on the first floor.

『NetFlixでパパのお勧めのコンテンツは何?』

"What's your favorite content on NetFlix?"

内容が簡単で、感動系で、短いもの、という注文をつけられました。

I was given an order that the content should be simple, touching, and short.

-----

江端家では、NetFlixの1月だけ契約というのを繰り返しています。

In the Ebata household, we have repeatedly signed up for NetFlix for only one month.

連休などの期間のある月だけ契約するのです。

I only sign up for months that have a period of time, such as consecutive holidays.

で、今月の契約期限があと数日になっており、現在、「NetFlixの駆け込み需要」が発生しております。

So, with this month's contract expiring in a few days, we are currently experiencing a "NetFlix rush".

-----

―― それでは 、アニメ『宇宙よりも遠い場所』を勧める

"Then I recommend a anime "A Place Farther Than the Universe""

内容について問われたので、"高校生"、"女の子"、"南極"、などのキーワードを挙げたら、嫁さんが渋い顔をしていました。

When asked about the contents of the book, I mentioned keywords such as "high school students," "girls," and "Antarctica," and my wife looked at me with a reluctant expression.

しかし、

However, I said to them,

『特に、第12話は、バイオレットエバーガーデンの"7話"と"10話"に匹敵する内容であることを保証する』

"In particular, I can assure you that episode 12 is comparable to episodes 7 and 10 of Violet Evergarden"

『もし、時間の無駄だったと思ったら、5万円支払ってもいい』

"If you think it was a waste of time, I'll pay you 50,000 yen.

と私が言い切ったこともあって、しぶしぶ見出したようです。

My wife reluctantly started watching it, because I assured her that I would do so.

-----

この賭け、私が勝つことは、もう分かっています。

I already know that I will win this bet.

2021/01,江端さんの忘備録

「働く細胞」というマンガが、これほど流行っているのに、

With a manga called "Working Cell" being so popular,

「働くコンピュータ」というマンガが登場してこないのは何故だろう ―― と考えています。

I've been wondering why there hasn't been a "Working Computer" manga.

-----

『コンピュータが働くのは、当たり前だろう』というのであれば、『細胞が働くのだって、当たり前だ』と反論します。

If you say, "It's natural for computers to work," then I would argue, "It's natural for cells to work, too.

しかし、細胞の擬人化に、これほどの魅力を感じるのは、

But what makes anthropomorphic cells so appealing,

言うまでもなく、原作者の方の才能と努力のたまものですが ―――

Needless to say, it is the result of the talent and efforts of the original author

細胞の持つ多様な能力や、他の細胞との関係性に、無数のバラエティがあるからで、その中にドラマを見い出せるからでしょう。

there are countless varieties in the various abilities of cells and their relationships with other cells, and I think this is because we can find drama in them.

-----

比して、コンピュータは、基本的にプログラムに命じられたことを、実施するだけの機械です。

A computer, on the other hand, is basically just a machine that does what the program tells it to do.

その動作には、原則として例外がありません(エラービットが発生しても、自己修正されます)。

In principle, there are no exceptions to its behavior (even if error bits occur, they are self-correcting).

プログラムの指示通りにしか動かない機械に「知能が発生する」という考え方が ―― やっぱり私には理解できないのです。

I still don't understand the idea of "intelligence" occurring in a machine that only works according to the instructions of a program.

-----

ですので ――

So...

だれか「働くコンピュータ」というマンガを描いて、私を納得させてくれないかなぁ、と思っています。

I'm wondering if someone could draw a manga called "Working Computers" to convince me to do so.

2020/07,江端さんの技術メモ

docker-compose.ymlの内容

version: '3.5'

services:
app:
build:
context: ./
dockerfile: docker/app/Dockerfile
target: build
command: ./main
depends_on:
- db
- tile38
volumes:
- ./:/XXXXXX_ride_hailing_go
db:
image: postgis-pgrouting:latest
build:
context: docker/postgis-pgrouting

expose:
- "5432"
ports:
- "15432:5432"
volumes:
- data
- ./:/XXXXX_ride_hailing_go
data:
image: busybox
volumes:
- "/data/db"
tile38:
image: tile38/tile38:1.17.0
expose:
- "9851"
ports:
- "19851:9851"
volumes:
- tile38_data
tile38_data:
image: busybox
volumes:
- "/data/tile38"
nginx:
image: nginx:1.15-alpine
ports:
- "80:80"
links:
- app:app
volumes:
- "./nginx.conf:/etc/nginx/conf.d/default.conf"

でもって、

XXXXXX_ride_hailing_go/docker/postgis-pgrouting/ の直下の Dockerfileの中身

FROM postgres:11.2
LABEL maintainer="dev@connect.co.jp"

ENV POSTGIS_MAJOR 2.5 →これもコメントアウト
ENV POSTGIS_VERSION 2.5.2+dfsg-1~exp1.pgdg90+1 → これはコロコロ変わるので注意のこと
ENV PGROUTING_MAJOR 2.5 → 最近は"3"になっている
ENV PGROUTING_VERSION 2.5.2
→コメントアウト

社内から使う時には、以下のプロキシの設定がないと動かない
ENV http_proxy http://12.34.56.789:8080
ENV https_proxy http://12.34.56.789:8080 ("http://" なのか "https://"なのかを間違えないように)

RUN apt-get update \
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
&& apt-get install -y --no-install-recommends \
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts=$POSTGIS_VERSION \
postgis=$POSTGIS_VERSION \
postgresql-$PG_MAJOR-pgrouting \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /docker-entrypoint-initdb.d
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/postgis.sh
COPY ./update-postgis.sh /usr/local/bin
COPY ./initdb-pgrouting.sh /docker-entrypoint-initdb.d/routing.sh

VOLUME /XXXXXX_ride_hailing_go
WORKDIR /XXXXXX_ride_hailing_go

の赤字の部分が原因で、以下のようなエラーが出ているらしい、というところまで分かった。

Reverse Provides:
Reading package lists…
Building dependency tree…
Reading state information…
E: Version '2.5.2+dfsg-1~exp1.pgdg90+1' for 'postgresql-11-postgis-2.5' was not found
E: Version '2.5.2+dfsg-1~exp1.pgdg90+1' for 'postgresql-11-postgis-2.5-scripts' was not found
E: Version '2.5.2+dfsg-1~exp1.pgdg90+1' for 'postgis' was not found

Service 'db' failed to build: The command '/bin/sh -c apt-get update && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR && apt-get install -y --no-install-recommends postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts=$POSTGIS_VERSION postgis=$POSTGIS_VERSION postgresql-$PG_MAJOR-pgrouting && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100

さて、どうも最新バージョンの問題だな、というところまでは分かたけど、何を入れたら良いのか分からず、2時間ほどすったもんだしていた。

このバージョンだが、docker-compose buildの最中に登場するので、見逃さないように

Reverse Depends:
postgresql-12-postgis-3-dbgsym,postgresql-12-postgis-3 3.1.0+dfsg-1.pgdg100+1
postgresql-12-postgis-3-scripts,postgresql-12-postgis-3
postgis-gui,postgresql-12-postgis-3
Dependencies:
3.1.0+dfsg-1.pgdg100+1 - postgresql-12 (0 (null)) postgresql-12-postgis-3-scripts (0 (null)) libc6 (2 2.14) libgcc1 (2 1:3.0) libgdal20 (2 2.0.1) libgeos-c1v5 (2 3.7.0) libjson-c3 (2 0.11) libpcre3 (0 (null)) libproj13 (2 4.9.0) libprotobuf-c1 (2 1.0.1) libsfcgal1 (2 1.3.1) libstdc++6 (2 5) libxml2 (2 2.7.4) postgis (3 1.2.1) postgis (0 (null))
Provides:
3.1.0+dfsg-1.pgdg100+1 - postgresql-postgis (= ) postgresql-12-postgis (= )
Reverse Provides:
Reading package lists…
Building dependency tree…
Reading state information…
E: Version '3.0.2+dfsg-4.pgdg+1' for 'postgresql-12-postgis-3' was not found

そこで、最近構築したPostgreSQLにログインして、色々情報を探ってみたら、

ca_sim-# \dx
List of installed extensions
Name | Version | Schema | Description
-----------+---------+------------+---------------------------------------------------------------------
pgrouting | 3.0.0 | public | pgRouting Extension
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
postgis | 3.0.0 | public | PostGIS geometry, geography, and raster spatial types and functions
(3 rows)

ca_sim-# select postgis_version();
3.0 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
(1 row)

ということが分かり、postgreSQLも、pgroutingも、postgisも、全部'3'になっていることが分った。そこで、docker-compose buildの画面に戻って、調べていたら、こんなメッセージを見つけた。

Reverse Depends:
postgresql-11-postgis-3,postgresql-11-postgis-3-scripts
Dependencies:
3.0.1+dfsg-4.pgdg90+1 - perl:any (0 (null)) postgresql-11-postgis-3 (0 (null)) postgresql-11-postgis-scripts (3 2.2.2+dfsg-3~)
Provides:
3.0.1+dfsg-4.pgdg90+1 - postgresql-postgis-scripts (= ) postgresql-11-postgis-scripts (= )
Reverse Provides:
Package: postgresql-11-postgis-3-dbgsym
Versions:
3.0.1+dfsg-4.pgdg90+1 (/var/lib/apt/lists/apt.postgresql.org_pub_repos_apt_dists_stretch-pgdg_main_binary-amd64_Packages.lz4)

なんか、これがクサいな、と思い、XXXXXX_ride_hailing_go/docker/postgis-pgrouting/ の直下の Dockerfileの中身を以下のように変えてみた。

FROM postgres:12.2
LABEL maintainer="dev@connect.co.jp"

ENV POSTGIS_MAJOR 3
ENV POSTGIS_VERSION 3.0.1+dfsg-4.pgdg100+1

# ENV PGROUTING_MAJOR 2.5
# ENV PGROUTING_VERSION 3.0.0
(上記2つの環境変数は、使われていないようだったのでコメントアウトしておいた)

この変更で、docker-compose build が無事通ることを確認した。

(あいかわらず、docker-compose.yml も Dockerfile も、よく分かっていないが、トライアンドエラーで何とかしている)

以上

=====

C:\Users\ebata\xxxxxxx_ride_hailing_go>docker-compose ps

xxxxxxx_ride_hailing_go_app_1 ./main Exit 1
xxxxxxx_ride_hailing_go_data_1 sh Exit 0
xxxxxxx_ride_hailing_go_db_1 docker-entrypoint.sh postgres Exit 1
xxxxxxx_ride_hailing_go_nginx_1 nginx -g daemon off; Up 0.0.0.0:80->80/tcp
xxxxxxx_ride_hailing_go_tile38_1 tile38-server -d /data Up 0.0.0.0:19851->9851/tcp
xxxxxxx_ride_hailing_go_tile38_data_1 sh Exit 0

となって、DBがどうしても動いてくれない問題発生。手動で起動を試みてみたら、こうなった。

C:\Users\ebata\xxxxxxx_ride_hailing_go>docker start -a xxxxxxx_ride_hailing_go_db_1
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

そこで、PostgresのDockerImageに変更があって起動ができなくなった話 を参照させて頂き、docker-compose.yml に

  POSTGRES_HOST_AUTH_METHOD: 'trust'
  POSTGRES_PASSWORD: 'postgres'

を追加して、

  db:
    image:  postgis-pgrouting:latest
    environment:
      POSTGRES_HOST_AUTH_METHOD: 'trust'
      POSTGRES_PASSWORD: 'postgres'
    build:
      context: docker/postgis-pgrouting
    expose:
      - "5432"
    ports:
      - "15432:5432"
    volumes:
      - data
      - ./:/xxxxxxx_ride_hailing_go
  data:
    image:  busybox
    volumes:
      - "/data/db"

のようにしてみて、再度 docker rmでコンテナ潰しておき、$ docker-compose build $ docker-compose up -d で、(さらに上手く動かない場合は) docker-compose restartを実施してみたら

C:\Users\ebata\xxxxxxx_ride_hailing_go>docker-compose restart
Restarting xxxxxxx_ride_hailing_go_nginx_1       ... done                                                                                                                                                              Restarting xxxxxxx_ride_hailing_go_app_1         ... done                                                                                                                                                              Restarting xxxxxxx_ride_hailing_go_data_1        ... done                                                                                                                                                              Restarting xxxxxxx_ride_hailing_go_tile38_data_1 ... done                                                                                                                                                              Restarting xxxxxxx_ride_hailing_go_db_1          ... done                                                                                                                                                              Restarting xxxxxxx_ride_hailing_go_tile38_1      ... done                                                                                                                                                              
C:\Users\ebata\xxxxxxx_ride_hailing_go>docker-compose ps
                Name                               Command              State             Ports
--------------------------------------------------------------------------------------------------------
xxxxxxx_ride_hailing_go_app_1           ./main                          Exit 1
xxxxxxx_ride_hailing_go_data_1          sh                              Exit 0
xxxxxxx_ride_hailing_go_db_1            docker-entrypoint.sh postgres   Up       0.0.0.0:15432->5432/tcp
xxxxxxx_ride_hailing_go_nginx_1         nginx -g daemon off;            Up       0.0.0.0:80->80/tcp
xxxxxxx_ride_hailing_go_tile38_1        tile38-server -d /data          Up       0.0.0.0:19851->9851/tcp
xxxxxxx_ride_hailing_go_tile38_data_1   sh                              Exit 0

となり、xxxxxxx_ride_hailing_go_db_1 docker-entrypoint.sh postgres Up 0.0.0.0:15432->5432/tcp を確認できるようになるに至った。

docker-compose run db psql -h db -U postgres -d gis -c 'CREATE EXTENSION pgrouting CASCADE; CREATE EXTENSION hstore;' で失敗した

失敗のメッセージはこんな感じ

C:\Users\ebata\xxxxxxx_ride_hailing_go>docker-compose run db psql -h db -U postgres -d gis -c 'CREATE EXTENSION pgrouting CASCADE; CREATE EXTENSION hstore;'
psql: warning: extra command-line argument "EXTENSION" ignored
psql: warning: extra command-line argument "pgrouting" ignored
psql: warning: extra command-line argument "CASCADE;" ignored
psql: warning: extra command-line argument "CREATE" ignored
psql: warning: extra command-line argument "EXTENSION" ignored
psql: warning: extra command-line argument "hstore;'" ignored
ERROR: unterminated quoted string at or near "'CREATE"
LINE 1: 'CREATE

ので、pgAdminで、xxxxxxx_ride_hailing_go のエントリーを作って接続してみたら、一応繋げた。

試しに、C:\Users\ebata\xxxxxxx_ride_hailing_go>docker-compose run db psql -h db -U postgres をやってみたら、ログインできて、こうなった

C:\Users\ebata\xxxxxxx_ride_hailing_go>docker-compose run db psql -h db -U postgres
psql (12.2 (Debian 12.2-2.pgdg100+1))
Type "help" for help.

postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+------------+------------+-----------------------
gis | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)

postgres=# \c gis
You are now connected to database "gis" as user "postgres".
gis=# \dt
Did not find any relations.
gis=#

やっぱり何も入っていないか。

ここから直接、

CREATE EXTENSION pgrouting CASCADE;
CREATE EXTENSION hstore;

を実行したら成功した。

次は、

C:\Users\ebata\xxxxxxx_ride_hailing_go>docker-compose run app migrate -database 'postgres://postgres:@db:5432/gis?sslmode=disable' -path ./repository/postgresql/migrations up
Starting xxxxxxx_ride_hailing_go_tile38_1 … done
Starting xxxxxxx_ride_hailing_go_db_1 … done
error: database: parse 'postgres://postgres:@db:5432/gis?sslmode=disable': first path segment in URL cannot contain colon

うーん、「コロンを消せ」と言われているようだけど、まあ、試してみる

C:\Users\ebata\xxxxxxx_ride_hailing_go>docker-compose run app migrate -database postgres://postgres:@db:5432/gis?sslmode=disable -path ./repository/postgresql/migrations up
Starting xxxxxxx_ride_hailing_go_db_1 … done Starting xxxxxxx_ride_hailing_go_tile38_1 … done 1/u create_administrators (43.041999ms)
2/u create_worlds (84.101398ms)
3/u create_passengers (126.189996ms)
4/u create_services (169.342395ms)
5/u create_bus_stops (237.856592ms)
6/u create_service_bus_stops (277.409391ms)
7/u create_waypoints (320.23459ms)
8/u create_trips (386.509487ms)
9/u add_pickuped_at_to_trips (410.829887ms)
10/u add_dissatisfaction_to_trips (437.705386ms)

通った。(ただ、その後、コンテナの再構築したら「コロンを消せ」のメッセージが出てこなくなった)。


その後、何度http://localhost をしても動かないので、試しに、http://localhost/admin/login から、 admin-0/password でログインできた。

「デモ世界の管理」を選択すると

が出てくるので、「地図表示」を選択すると、例の画面が出てきた。

そういえば、データの生成は、以下のコマンドで。

docker-compose run app go run cmd/dummy_data_generator_concurrent_small/main.go

ああ、疲れた。(これで、ようやく眠れる)

==========

$ cd /path/to/hitachi_ride_hailing_go
$ docker-compose build
# 上記部分が完了するまで、はじめての場合はネットワーク環境により数分かかります
$ docker-compose up -d
$ docker-compose run db createdb -h db -U postgres gis
$ docker-compose run db psql -h db -U postgres -d gis -c 'CREATE EXTENSION pgrouting CASCADE; CREATE EXTENSION hstore;'
$ docker-compose run db psql -h db -U postgres gis < repository/postgresql/data/dump.sql
$ docker-compose run db psql -h db -U postgres -d gis -f repository/postgresql/data/postgis-vt-util.sql
$ docker-compose stop
$ docker-compose start
$ docker-compose run app migrate -database 'postgres://postgres:@db:5432/gis?sslmode=disable' -path ./repository/postgresql/migrations up
$ docker-compose run app go run cmd/dummy_data_generator_concurrent_small/main.go
$ docker-compose stop
$ docker-compose start

Windows10のコマンドプロンプトではなく、MinGW64のシェルを使うと調子がいい

==========

2021/01,江端さんの技術メモ

/etc/apt/apt.confに

1
2
3
Acquire::http::Proxy "http://proxy server : port 番号";
Acquire::https::Proxy "https://proxy server : port 番号";
("s"をつけるとマズい時もある)
Acquire::ftp::Proxy "ftp://proxy server : port 番号";

を追記してみたら、apt-get update できるようになった。pingなどは通る。

curl http://sample.com では、コマンドも戻ってこない。

 

明日は、

(1)シェルを変えてみる。

1
2
3
export http="http://proxy server : port 番号"
export https="https://proxy server : port 番号"
export ftp="ftp://proxy server : port 番号
1
printenv | grep -i proxy

/etc/apt/sources.listの内容を確認する

 

https://qiita.com/tkyonezu/items/0f6da57eb2d823d2611d から

3. スクリプトでのインストール

+ sh -c
echo
"deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial edge"
> /etc/apt/sources.list.d/docker.list

 

https://askubuntu.com/questions/1230189/how-to-install-docker-community-on-ubuntu-20-04-lts

2021/01,江端さんの技術メモ

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: proxyconnect tcp: tls: oversized record received with length 20527.
See 'docker run --help'.

で、5~6日間、苦しめられて、今もまだ完全には解決していないけど、酷いオチだったのでメモを残しておく

環境:  AWS EC2:Ubuntu20.04

状況: この問題、世界中のエンジニアを悩ませているらしい

条件: 個人の環境によって、まったく役に立たない情報であることがある。これはたまたま私(江端)の環境で上手くいっただけのものである(故に、私に質問しても無駄である)

助けて頂いた資料:  Proxy環境でdockerを外に繋ぐ方法 

修正前:

/etc/systemd/system/docker.service.d/http-proxy.conf を力づくで作った(最初はなかった(みたい))。

[Service]
Environment="HTTP_PROXY=http://12.34.56.789:8080/" "HTTPS_PROXY=https://12.34.56.789:8080" "NO_PROXY=localhost,127.0.0.1,.12.34.56.789"

修正後:

[Service]
Environment="HTTP_PROXY=http://12.34.56.789:8080/" "HTTPS_PROXY=http://12.34.56.789:8080" "NO_PROXY=localhost,127.0.0.1,.12.34.56.789"

(なんのことはない、HTTPS_PROXY の "https:"→"http:" としただけ。ただし、これは、個々の環境に依存する問題だと思う)

ちなみに私のところでは徒労だった(と思われる)作業:

$ host registry-1.docker.io
registry-1.docker.io has address 52.72.232.213
registry-1.docker.io has address 54.85.56.253
registry-1.docker.io has address 54.236.165.68
registry-1.docker.io has address 3.211.199.249
registry-1.docker.io has address 18.213.137.78
registry-1.docker.io has address 18.232.227.119
registry-1.docker.io has address 52.20.56.50
registry-1.docker.io has address 52.54.232.21

と調べた後で、/etc/hostsに書き込んだ

127.0.0.1 localhost
23.22.155.84 registry-1.docker.io
34.195.246.183 registry-1.docker.io
35.174.73.84 registry-1.docker.io
52.5.11.128 registry-1.docker.io
52.20.56.50 registry-1.docker.io
52.54.232.21 registry-1.docker.io
107.23.149.57 registry-1.docker.io
18.232.227.119 registry-1.docker.io

これ↓もダメだった

$ docker run hello-world --dns 12.34.56.789:8080/

これ↓もダメだった

export http="http://proxy server : port 番号"
export https="https://proxy server : port 番号"
export ftp="ftp://proxy server : port 番号

現状、未解決な問題:

"E: Unable to locate package docker-engine"

以上