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"

以上

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

なぜ、動き出したのか分からないので、historyを残しておく

1 ;s
2 pwd
3 ls
4 ;
5 :
6 pwd
7 ls
8 whoami
9 pwd
10 ls
11 pwd
12 ls
13 ping kobore.net
14 ls
15 pwd
16 ls
17 pwd
18 ls
19 sudo apt-get update
20 sudo apt-get install
21 sudo apt-get upgrade
22 ls
23 ls
24 ls -al
25 pwd
26 ls
27 wd
28 ls
29 pwd
30 ls
31 exit
32 ls
33 pwd
34 ls
35 sudo apt-get install
36 sudo apt-get update
37 ls
38 pwd
39 ls
40 pwd
41 ls
42 sudo apt-get install emacs
43 sudo apt-get install vim
44 emacs
45 sudo apt-get install emacs-nox
46 emacs-nox
47 sudo apt install emacs-nox
48 ping kobore.net
49 ping amazon.com
50 ls
51 pwd
52 ls
53 gcc
54 pwd
55 ls
56 cd /usr
57 cd local
58 cd bimn
59 cd bin
60 ls
61 pwd
62 cd /bin
63 ls
64 printenv http_proxy
65 printenv http_proxy https_proxy
66 export https_proxy=$http_proxy
67 sudo apt-get update
68 printenv http_proxy
69 printenv http_proxy https_proxy
70 history
71 export http_proxy="12.34.56.789:8080"
72 export https_proxy=$http_proxy
73 printenv http_proxy https_proxy
74 sudo apt-get update
75 ping kobore.net
76 ping hitachi.com
77 ping amazon.com
78 export http_proxy="http://12.34.56.789:8080"
79 export https_proxy=$http_proxy
80 printenv http_proxy https_proxy
81 sudo apt-get update
82 export http_proxy="http://12.34.56.789:8080"
83 export https_proxy=$http_proxy
84 printenv http_proxy https_proxy
85 sudo apt-get update
86 sudo apt-get install
87 sudo apt-get upgrade
88 sudo apt-get update
89 export http_proxy="http://12.34.56.789:8080"
90 EXPORT HTTP_PROXY=http://12.34.56.789:8080
91 EXPORT HTTP_PROXY="http://12.34.56.789:8080"
92 export HTTP_PROXY="http://12.34.56.789:8080"
93 export HTTP_PROXY=http://12.34.56.789:8080
94 printenv http_proxy https_proxy
95 sudo apt-get update
96 sudo apt-get install emacs
97 emacs
98 sudo apt install emacs-nox
99 export
100 history
101 printenv http_proxy https_proxy
102 emacs
103 sudo apt install emacs-nox
104 apt install emacs
105 clear
106 apt install emacs
107 ping amazon.com
108 sudo apt-get install
109 sudo apt-get update
110 cat apt.conf
111 vim
112 vim /etc/apt/apt.conf
113 sudo vim
114 sudo vim /etc/apt/apt.conf
115 more /etc/apt/apt.conf
116 cd
117 sudo apt-get update
118 sudo apt-get upgrade
119 sudo apt-get install emacs
120 pwd
121 ls
122 emac
123 emacs
124 sudo emacs /etc/apt/apt.conf
125 ls
126 pwd
127 ls
128 pwd
129 ls
130 pwd
131 ls
132 pwd
133 ls
134 pwd
135 ls
136 pwd
137 ls
138 sudo apt-get install
139 exit
140 ,s
141 ls
142 sudo apt-get remove docker docker-engine docker.io containerd runc
143 sudo apt-get update
144 sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
145 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
146 sudo apt-gey gpg
147 sudo apt-key gpg
148 sudo apt-key add gpg
149 sudo apt-key fingerprint 0EBFCD88
150 gpg
151 sudo apt-key fingerprint 0EBFCD88
152 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
153 sudo apt-get update
154 sudo apt-get install docker-ce docker-ce-cli containerd.io
155 sudo apt-get install docker-ce
156 sudo apt-get install containerd.io
157 apt update
158 ls
159 sudo apt-get install
160 sudo apt-get update
161 sudo apt-get upgrade
162 sudo apt-get install
163 sudo apt-get remove docker docker-engine docker.io containerd runs
164 sudo apt-get remove docker docker-engine docker.io containerd runc
165 sudo apt-get update
166 sudo apt-get install docker-ce docker-ce-cli containerd.io
167 sudo apt-get install docker-ce
168 sudo apt-get remove docker
169 sudo apt-get remove docker-engine
170 sudo apt-get remove docker.io
171 sudo apt-get remove docker-engine
172 sudo apt-get remove docker
173 sudo apt autoremove docker
174 sudo apt autoremove docker-engine
175 sudo apt autoremove docke-ce
176 sudo apt autoremove docker-ce
177 sudo apt autoremove docker-cli
178 sudo apt autoremove docker-ce
179 sudo apt autoremove docker-ce-cli
180 sudo apt autoremove containerd.op
181 sudo apt autoremove containerd.io
182 docker
183 sudo reboot
184 curl -L kobore.net
185 ping kobore.bet
186 ping kobore.met
187 ping kobore.net
188 vf /udt
189 cd /ysr
190 cd /usr
191 cd share/
192 cd
193 cd /etc
194 s
195 ls
196 cd
197 cd curl --help
198 curl --help
199 curl --help | grep proxy
200 curl -X PUT http://kobore.net
201 curl -k http://kobore.net
202 curl -I http://kobore.net
203 sudo apt-get install curl
204 sudo apt-get remove curl
205 curl
206 sudo apt-get install curl
207 curl
208 curl -L http://kobore.net
209 more
210 cd /etc/
211 ls
212 curl -L http://localhost
213 curl -L https://amazon.com
214 sudo apt-get install emacs
215 nslookup kobore.net
216 nslookup www.google.com
217 curl --version
218 curl localhost
219 curl -sS 'https://kobore.net'
220 curl http://kobore.net
221 more /etc/apt/apt.conf
222 export http="http://12.34.56.789.4:8080"
223 export https="http://12.34.56.789.4:8080"
224 curl http://kobore.net
225 printenv
226 sudo apt-get remove docker docker-engine docker.io containerd runc
227 ls
228 cd
229 pwd
230 ls
231 ks
232 ls
233 wd
234 ls
235 lsb_release -cs
236 curl kobore.net
237 sudo apt-key fingerprint 0EBFCD88
238 sudo emacs /etc/apt/sources.list
239 sudo apt-get update
240 cat /etc/apt/sources.list
241 cd
242 apt-cache madison docker-ce
243 sudo apt-get install docker-ce=5:19.03.13~3-0~ubuntu-focal docker-ce-cli=5:19.03.13~3-0~ubuntu-focal containerd.ioCopy
244 sudo apt-get install docker-ce=5:19.03.13~3-0~ubuntu-focal docker-ce-cli=5:19.03.13~3-0~ubuntu-focal containerd.io
245 sudo apt-get install docker-ce=5:19.03.13~3-0~ubuntu-focal docker-ce-cli=5:19.03.13~3-0~ubuntu-focal containerd.ioCopy
246 Markup
247 sudo apt-get install docker-ce=5:19.03.13~3-0~ubuntu-focal docker-ce-cli=5:19.03.13~3-0~ubuntu-focal containerd.io
248 sudo apt-get install docker-ce docker-ce-cli containerd.io
249 sudo apt-get install docker-ce
250 E: Package 'docker-ce' has no installation candidate
251 sjdl
252 sudo apt install docker-ce
253 Package docker-ce is not available, but is referred to by another package.
254 history
255 cat /etc/apt/sources.list
256 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
257 E: The repository 'https://download.docker.com/linux/ubuntu focal Release' does not have a Release file.
258 ls
259 sudo emcs /etc/apt/sources.list
260 sudo emacs /etc/apt/sources.list
261 sudo apt install docker-ce
262 sudo apt remove docker-ce
263 sudo apt
264 cat /etc/apt/sources.list
265 sudo emacs /etc/apt/sources.list.d/docker.list
266 history
267 sudo apt-get remove docker docker-engine docker.io containerd runc
268 sudo apt-get install docker docker-engine docker.io containerd runc
269 sudo apt-get install docker docker.io containerd runc
270 sudo apt-get remove docker docker.io containerd runc
271 history
272 sudo emacs /etc/apt/sources.list.d/docker.list
273 sudo apt-get remove docker docker.io containerd runc
274 sudo apt autoremove docker docker.io containerd runc
275 sudo apt install docker docker.io containerd runc
276 sudo apt install docker-engine
277 docker
278 dokcer ps
279 docker ps
280 sudo gpasswd -a $(whoami) docker
281 sudo gpasswd -a USER_NAME docker
282 sudo gpasswd -a $(whoami) docker
283 whoami
284 more /etc/group
285 history
286 whoami
287 sudo gpasswd -a $(whoami) docker
288 cat /etc/group | grep docker
289 sudo emacs /etc/group
290 sudo gpasswd -a $(whoami) docker
291 docker ps
292 Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/
293 sudo emacs /etc/group
294 sudo groupadd docker
295 whoami
296 cat /etc/grou | grep docker
297 more /etc/group
298 sudo emacs /etc/group
299 cat /etc/grou | grep docker
300 cat /etc/group | grep docker
301 history
302 sudo gpasswd -a $(whoami) docker
303 sudo /bin/systemctl restart docker.service
304 docker info
305 docker ps
306 exit
307 docker ps
308 docker info
309 history

/etc/default/docker

export http_proxy=http://xxx.xxx.xxx.xxx:8080/
export https_proxy=http://xxx.xxx.xxx.xxx:8080/

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

背景はこちら。

curlが動かない件について、明日試すこと(後で消す)

会社の方に教えて貰ったのがこちら

curlコマンドにてproxy設定

を参考にしながら、手抜き(taro:passwordを省略)で、

$ curl kobore.net -x http:192.168.1.1:8080

としてみたが、通った。

現在は、~/.curlrc に

proxy=http:192.168.1.1:8080

と書き込んで使用中。

 

キーワード: curl proxy