Skip to content

Commit dad10ae

Browse files
authored
Merge pull request #1212 from openml/feature/dockerfile
PhP docker file
2 parents 9f9c171 + a7b6197 commit dad10ae

File tree

9 files changed

+2302
-0
lines changed

9 files changed

+2302
-0
lines changed

docker/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM php:7.4.33-apache
2+
3+
RUN docker-php-source extract \
4+
&& docker-php-ext-install mysqli \
5+
&& docker-php-source delete
6+
7+
RUN apt-get update \
8+
&& apt-get install -y git
9+
10+
COPY . /var/www/openml
11+
12+
RUN mv /var/www/openml/openml_OS/config/BASE_CONFIG-BLANK.php /var/www/openml/openml_OS/config/BASE_CONFIG.php
13+
14+
RUN mkdir /var/www/openml/logs
15+
RUN mkdir /data
16+
17+
18+
COPY docker/config/*.load /etc/apache2/mods-enabled/
19+
COPY docker/config/api.conf /etc/apache2/sites-enabled/000-default.conf
20+
COPY docker/config/php.ini /usr/local/etc/php/
21+
COPY docker/config/.htaccess /var/www/openml/.htaccess
22+
23+
COPY docker/set_configuration.sh /scripts/
24+
25+
26+
WORKDIR /var/www/openml
27+
ENTRYPOINT ["bash", "/scripts/set_configuration.sh"]

docker/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Running apache php backend locally
2+
3+
In most cases, you probably want to run through docker compose.
4+
This file contains instructions for running it on its own.
5+
6+
```bash
7+
docker run -p 8001:80 --rm -it openml/php-rest-api
8+
```
9+
10+
Runs the PHP REST API server and exposes it to `http://localhost:8001/`.
11+
Some `BASE_CONFIG.php` variables can be overwritten with environment variables,
12+
these can be passed in the run command with the `-e` option, e.g.: `-e BASE_URL=http://localhost/`.
13+
See `set_configuration.sh` for the variables which can be overwritten out-of-the-box.
14+
Alternatively, mount your own `BASE_CONFIG.php` into the container at `/var/www/openml/openml_OS/config/BASE_CONFIG.php`.
15+
The `set_configuration.sh` script will only overwrite unset variables.
16+
To avoid overwriting altogether, also change the entrypoint: `--entrypoint=apache2-foreground`.
17+
18+
To connect to a separate container running a MySQL server, they need to be on the same docker network.
19+
For both, specify the network with `--network NETWORK_NAME`, which can be any network you create with `docker network create NETWORK_NAME`.
20+
Assuming a connection to the database can be established, to get a dataset description go to `http://127.0.0.1:8001/api/v1/json/data/1`.
21+
Note that the protocol is `http` not `https`.
22+
23+
24+
## Build
25+
26+
```bash
27+
docker build --tag openml/php-rest-api -f docker/Dockerfile .
28+
```

docker/config/.htaccess

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
RewriteEngine on
2+
3+
# TODO: specific for main instance of OpenML site. Should do something better
4+
RewriteCond %{HTTP_HOST} ^api_new.openml.org
5+
RewriteRule ^(.*)$ http://www.openml.org/api_new/$1 [L,P]
6+
7+
RewriteCond %{HTTPS_HOST} ^api_new.openml.org
8+
RewriteRule ^(.*)$ https://www.openml.org/api_new/$1 [L,P]
9+
10+
RewriteCond $1 !^(questions|SWF|img|docs|downloads|GFX|favicon\.ico|tiny_mce|index\.php|js|css|robots\.txt)
11+
RewriteRule ^(.*)$ index.php/$1 [L]
12+
13+
14+
<IfModule mod_headers.c>
15+
Header set Access-Control-Allow-Origin "*"
16+
Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"
17+
</IfModule>
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
<?php
2+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3+
* After editing this file, rename to BASE_CONFIG.php
4+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5+
6+
7+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
8+
* Sets the local time to a specific zone. Can be removed, if it is
9+
* set in php.ini.
10+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
11+
setlocale(LC_TIME, 'nl_NL');
12+
13+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
14+
* BASE_URL: The domain of the instance, along with the folder where
15+
* it can be found. Also with a tailing slash. For the main instance
16+
* of OpenML, this would be http://www.openml.org/. For an instance on
17+
* a localhost, this would be http://localhost/.
18+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
19+
define( 'BASE_URL', 'FILL_IN' );
20+
21+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
22+
* DATA_URL: The subdirectory where the data can be accessed. Will be
23+
* deprecated in a few updates.
24+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
25+
define( 'DATA_URL', BASE_URL . 'data/' );
26+
27+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
28+
* MINIO_URL: MINIO Server URL. Currently this is 'http://openml1.win.tue.nl/'.
29+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
30+
define( 'MINIO_URL', 'FILL_IN' );
31+
32+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
33+
* PATH: The directory on the hard disk where the instance of OpenML
34+
* can be found, with tailing slash. Typically, this would be
35+
* something like /var/www/ (on Ubuntu installations)
36+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
37+
define( 'PATH', 'FILL_IN' );
38+
39+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
40+
* DATA_PATH: The directory on whether the uploaded data is stored.
41+
* It might be a good idea to locate this directory outside of the
42+
* webserver directory. Should be writeable for webserver.
43+
* IMPORTANT NOTE: If you choose to change the value indicated below
44+
* (PATH . 'data/') into something different, make sure to also move
45+
* the content of the data directory that was provided at installation.
46+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
47+
define( 'DATA_PATH', PATH . 'data/' );
48+
49+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
50+
* TMP_PATH: Directory in which temporary files can be places. LOCK
51+
* files are an example of these kind of files. /tmp/ is generally a
52+
* good place on Unix based systems.
53+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
54+
define( 'TMP_PATH', '/tmp/' );
55+
56+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
57+
* Paths for server-side scripts
58+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
59+
define( 'LIB_PATH', '/var/lib/' );
60+
61+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
62+
* Configuration details for the experiment database
63+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
64+
* DB_NAME: The name of the database
65+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
66+
* DB_HOST: The host of the database (typically: localhost)
67+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
68+
* DB_USER: The username to connect to the database. IMPORTANT: This
69+
* account is used by the free query interface. This username should
70+
* only contain READ (SELECT, DESCRIBE) access to the database
71+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
72+
* DB_PASS: The password that belongs to the username
73+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
74+
* DB_USER_WRITING: A user account that can also WRITE (SELECT,
75+
* UPDATE, INSERT, DELETE) to the database. Administrative privileges
76+
* are discouraged.
77+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
78+
* DB_PASS_WRITING: The password that belongs to the DB_USER_WRITING
79+
* account.
80+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
81+
define( 'DB_NAME_EXPDB', 'FILL_IN' );
82+
define( 'DB_HOST_EXPDB', 'FILL_IN' );
83+
define( 'DB_USER_EXPDB_READ', 'FILL_IN' );
84+
define( 'DB_PASS_EXPDB_READ', 'FILL_IN' );
85+
define( 'DB_USER_EXPDB_WRITE', 'FILL_IN' );
86+
define( 'DB_PASS_EXPDB_WRITE', 'FILL_IN' );
87+
88+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
89+
* Configuration details for the OpenML database (User accounts, etc.)
90+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
91+
* DB_NAME_COMMUNITY: The name of the database
92+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
93+
* DB_HOST_COMMUNITY: The host of the database (typically: localhost)
94+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
95+
* DB_USER_COMMUNITY: The username to connect to the database. Should
96+
* have SELECT, INSERT, UPDATE and DELETE privileges.
97+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
98+
* DB_PASS: The password that belongs to the username
99+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
100+
define( 'DB_NAME_OPENML', 'FILL_IN' );
101+
define( 'DB_HOST_OPENML', 'FILL_IN' );
102+
define( 'DB_USER_OPENML', 'FILL_IN' );
103+
define( 'DB_PASS_OPENML', 'FILL_IN' );
104+
105+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
106+
* Configuration details for the OpenML API (Username, password)
107+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
108+
* API_USERNAME: The username under which the system may perform API
109+
* calls.
110+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
111+
* API_KEY: The API_KEY that belongs to the username
112+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
113+
define( 'API_USERNAME', 'FILL_IN_USERNAME' );
114+
define( 'API_KEY', 'FILL_IN_KEY' );
115+
116+
117+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
118+
* Configuration details for the ElasticSearch server (Username, password)
119+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
120+
* ES_USERNAME and ES_PASSWORD can be set by ElasticSearch or a protected proxy
121+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
122+
define( 'ES_URL', 'FILL_IN' );
123+
define( 'ES_USERNAME', 'FILL_IN' );
124+
define( 'ES_PASSWORD', 'FILL_IN' );
125+
126+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
127+
* Configuration details for the Wiki server (Username, password)
128+
* We use the Gollem Wiki Engine
129+
* WIKI_USERNAME and WIKI_PASSWORD can be set by a protected proxy
130+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
131+
define( 'WIKI_URL', 'localhost:443/wiki' );
132+
define( 'WIKI_USERNAME', 'username' );
133+
define( 'WIKI_PASSWORD', 'password' );
134+
135+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * *
136+
* * * * * *
137+
* DEBUG: Will produce errors and warnings on the screen. Set this
138+
* to true when developing. Set to false on the production server
139+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
140+
define( 'DEBUG', FALSE );
141+
142+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * *
143+
* * * * * *
144+
* DEBUG_XSD_EMAIL: Will send debug information for failed XSD
145+
* validations to the user who initiated it
146+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
147+
define( 'DEBUG_XSD_EMAIL', FALSE );
148+
149+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
150+
* CMD_PREFIX: Adds a prefix to all shell commands; needed for bugfix
151+
* on some MAMP (OSX) systems. Can be left empty on all other systems.
152+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
153+
define( 'CMD_PREFIX', '');
154+
155+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
156+
* EMAIL_FROM: The email address from which the emails will be send.
157+
* Use the domain name specified in the BASE_URL
158+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
159+
define( 'EMAIL_FROM', '[email protected]' );
160+
161+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
162+
* EMAIL_API_LOG: The email address to which critical API errors
163+
* get reported
164+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
165+
define( 'EMAIL_API_LOG', '[email protected]' );
166+
167+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
168+
* EXTERNAL API SETTINGS
169+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
170+
* EXTERNAL_API_PROXY: Set this to true if you want to use a proxy
171+
* for communication with external proxies. In general, you don't
172+
* need this (and can skip this block by setting this to false).
173+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
174+
* EXTERNAL_API_PROXY_PORT: The port of the proxy
175+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
176+
* EXTERNAL_API_PROXY_URL: The URL of the proxy
177+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
178+
* EXTERNAL_API_PASSWORD: The password of the proxy
179+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
180+
define( 'EXTERNAL_API_PROXY', FALSE );
181+
define( 'EXTERNAL_API_PROXY_PORT', '' );
182+
define( 'EXTERNAL_API_PROXY_URL', '' );
183+
define( 'EXTERNAL_API_PASSWORD', '' );
184+
185+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
186+
* EXTERNAL API KEYS - The public and private keys of the external api's
187+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
188+
* Typically, an external api provides us with a public keyb
189+
* (FACEBOOK_APP_ID, TWITTER_CONSUMER_KEY, GOOGLE_CLIENT_ID) and a
190+
* private key (FACEBOOK_APP_SECRET, TWITTER_CONSUMER_SECRET,
191+
* GOOGLE_CLIENT_SECRET). These are to be filled in here.
192+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
193+
define( 'FACEBOOK_APP_ID', 'xxx' );
194+
define( 'FACEBOOK_APP_SECRET', 'xxx' );
195+
define( 'TWITTER_CONSUMER_KEY', 'xxx' );
196+
define( 'TWITTER_CONSUMER_SECRET', 'xxx' );
197+
define( 'GOOGLE_CLIENT_ID', 'xxx.apps.googleusercontent.com' );
198+
define( 'GOOGLE_CLIENT_SECRET', 'xxx' );
199+
?>

docker/config/api.conf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
User www-data
2+
Group www-data
3+
4+
LogFormat "%h %l %u %t \"%r\" %>s %b" common
5+
ErrorLog /var/www/openml/logs/error.log
6+
CustomLog /var/www/openml/logs/access.log common
7+
8+
HostnameLookups Off
9+
10+
11+
<Directory />
12+
Options FollowSymLinks
13+
AllowOverride None
14+
Require all denied
15+
</Directory>
16+
17+
<Directory /var/www/openml>
18+
Options Indexes FollowSymLinks MultiViews
19+
AllowOverride All
20+
Require all granted
21+
</Directory>
22+
23+
<VirtualHost *:80>
24+
DocumentRoot /var/www/openml
25+
RewriteEngine on
26+
RewriteCond %{SERVER_NAME} =api.openml.org
27+
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
28+
</VirtualHost>

docker/config/headers.load

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so

0 commit comments

Comments
 (0)