Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb8a54e4

Browse files
authored
Merge pull request#5 from postgresml/dockerized-build
docker
2 parents09a4823 +3e5e851 commitb8a54e4

File tree

6 files changed

+905
-22
lines changed

6 files changed

+905
-22
lines changed

‎Dockerfile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
FROM ubuntu:20.04
2+
MAINTAINER docker@postgresml.com
3+
24
RUN apt-get update
35
ARG DEBIAN_FRONTEND=noninteractive
46
ENV TZ=Etc/UTC
5-
RUN apt-get install -y tzdata
6-
RUN apt-get install -y postgresql-plpython3-12 python3 python3-pip postgresql-12
7-
RUN pip3 install sklearn
8-
RUN apt-get install sudo -y
9-
COPY . /app
7+
RUN apt-get install -y postgresql-plpython3-12 python3 python3-pip postgresql-12 tzdata sudo
8+
9+
COPY --chown=postgres:postgres . /app
1010
WORKDIR /app/pgml
11+
12+
# Install pgml extension globally.
1113
RUN python3 setup.py install
14+
15+
# Listen on 0.0.0.0 and allow 'root' to connect without a password.
16+
# Please modify for production deployments accordingly.
17+
RUN cp /app/docker/postgresql.conf /etc/postgresql/12/main/postgresql.conf
18+
RUN cp /app/docker/pg_hba.conf /etc/postgresql/12/main/pg_hba.conf
19+
1220
WORKDIR /app
13-
ENTRYPOINT ["/bin/bash","/app/entrypoint.sh"]
21+
ENTRYPOINT ["/bin/bash","/app/docker/entrypoint.sh"]

‎docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version:"3"
2+
services:
3+
postgres:
4+
build:
5+
context:./
6+
dockerfile:Dockerfile
7+
ports:
8+
-"5433:5432"
9+
volumes:
10+
-"pg_data:/var/lib/postgresql"
11+
command:
12+
-sleep
13+
-infinity
14+
15+
volumes:
16+
pg_data:

‎docker/entrypoint.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
service postgresql start
3+
while! sudo -u postgres psql -c'SELECT 1'> /dev/null;do
4+
sleep 1
5+
done
6+
echo"Creating user and database..."
7+
sudo -u postgres createuser root --superuser2> /dev/null
8+
sudo -u postgres createdb root2> /dev/null
9+
10+
echo"Installing pgml extension..."
11+
psql -q -f sql/install.sql> /dev/null
12+
13+
echo"Ready"
14+
15+
if [[!-z$@ ]];then
16+
echo
17+
echo"To connect to the database:"
18+
echo" psql -p 5433 -h 127.0.0.1 -U root"
19+
echo
20+
$@
21+
fi

‎docker/pg_hba.conf

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# PostgreSQL Client Authentication Configuration File
2+
# ===================================================
3+
#
4+
# Refer to the "Client Authentication" section in the PostgreSQL
5+
# documentation for a complete description of this file. A short
6+
# synopsis follows.
7+
#
8+
# This file controls: which hosts are allowed to connect, how clients
9+
# are authenticated, which PostgreSQL user names they can use, which
10+
# databases they can access. Records take one of these forms:
11+
#
12+
# local DATABASE USER METHOD [OPTIONS]
13+
# host DATABASE USER ADDRESS METHOD [OPTIONS]
14+
# hostssl DATABASE USER ADDRESS METHOD [OPTIONS]
15+
# hostnossl DATABASE USER ADDRESS METHOD [OPTIONS]
16+
# hostgssenc DATABASE USER ADDRESS METHOD [OPTIONS]
17+
# hostnogssenc DATABASE USER ADDRESS METHOD [OPTIONS]
18+
#
19+
# (The uppercase items must be replaced by actual values.)
20+
#
21+
# The first field is the connection type: "local" is a Unix-domain
22+
# socket, "host" is either a plain or SSL-encrypted TCP/IP socket,
23+
# "hostssl" is an SSL-encrypted TCP/IP socket, and "hostnossl" is a
24+
# non-SSL TCP/IP socket. Similarly, "hostgssenc" uses a
25+
# GSSAPI-encrypted TCP/IP socket, while "hostnogssenc" uses a
26+
# non-GSSAPI socket.
27+
#
28+
# DATABASE can be "all", "sameuser", "samerole", "replication", a
29+
# database name, or a comma-separated list thereof. The "all"
30+
# keyword does not match "replication". Access to replication
31+
# must be enabled in a separate record (see example below).
32+
#
33+
# USER can be "all", a user name, a group name prefixed with "+", or a
34+
# comma-separated list thereof. In both the DATABASE and USER fields
35+
# you can also write a file name prefixed with "@" to include names
36+
# from a separate file.
37+
#
38+
# ADDRESS specifies the set of hosts the record matches. It can be a
39+
# host name, or it is made up of an IP address and a CIDR mask that is
40+
# an integer (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that
41+
# specifies the number of significant bits in the mask. A host name
42+
# that starts with a dot (.) matches a suffix of the actual host name.
43+
# Alternatively, you can write an IP address and netmask in separate
44+
# columns to specify the set of hosts. Instead of a CIDR-address, you
45+
# can write "samehost" to match any of the server's own IP addresses,
46+
# or "samenet" to match any address in any subnet that the server is
47+
# directly connected to.
48+
#
49+
# METHOD can be "trust", "reject", "md5", "password", "scram-sha-256",
50+
# "gss", "sspi", "ident", "peer", "pam", "ldap", "radius" or "cert".
51+
# Note that "password" sends passwords in clear text; "md5" or
52+
# "scram-sha-256" are preferred since they send encrypted passwords.
53+
#
54+
# OPTIONS are a set of options for the authentication in the format
55+
# NAME=VALUE. The available options depend on the different
56+
# authentication methods -- refer to the "Client Authentication"
57+
# section in the documentation for a list of which options are
58+
# available for which authentication methods.
59+
#
60+
# Database and user names containing spaces, commas, quotes and other
61+
# special characters must be quoted. Quoting one of the keywords
62+
# "all", "sameuser", "samerole" or "replication" makes the name lose
63+
# its special character, and just match a database or username with
64+
# that name.
65+
#
66+
# This file is read on server startup and when the server receives a
67+
# SIGHUP signal. If you edit the file on a running system, you have to
68+
# SIGHUP the server for the changes to take effect, run "pg_ctl reload",
69+
# or execute "SELECT pg_reload_conf()".
70+
#
71+
# Put your actual configuration here
72+
# ----------------------------------
73+
#
74+
# If you want to allow non-local connections, you need to add more
75+
# "host" records. In that case you will also need to make PostgreSQL
76+
# listen on a non-local interface via the listen_addresses
77+
# configuration parameter, or via the -i or -h command line switches.
78+
79+
80+
81+
82+
# DO NOT DISABLE!
83+
# If you change this first entry you will need to make sure that the
84+
# database superuser can access the database using some other method.
85+
# Noninteractive access to all databases is required during automatic
86+
# maintenance (custom daily cronjobs, replication, and similar tasks).
87+
#
88+
# Database administrative login by Unix domain socket
89+
local all postgres peer
90+
91+
# TYPE DATABASE USER ADDRESS METHOD
92+
93+
# "local" is for Unix domain socket connections only
94+
local all all peer
95+
# IPv4 local connections:
96+
host all all 0.0.0.0/0 trust
97+
# IPv6 local connections:
98+
host all all ::1/128 md5
99+
# Allow replication connections from localhost, by a user with the
100+
# replication privilege.
101+
local replication all peer
102+
host replication all 0.0.0.0/0 md5
103+
host replication all ::1/128 md5

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp