Adapt multi-process image to work with updated single-process base image

Dominik Sander 8 jaren geleden
bovenliggende
commit
3dc3a1ec9a

+ 4 - 1
docker/multi-process/Dockerfile

@@ -1,8 +1,11 @@
1
-FROM dsander/huginn-single-process:latest
1
+FROM cantino/huginn-single-process:latest
2 2
 MAINTAINER Andrew Cantino
3 3
 
4 4
 WORKDIR /app
5 5
 
6
+ADD scripts/standalone-packages /scripts/standalone-packages
7
+RUN /scripts/standalone-packages
8
+
6 9
 ADD scripts/init /scripts/init
7 10
 
8 11
 VOLUME /var/lib/mysql

+ 7 - 56
docker/multi-process/README.md

@@ -27,9 +27,9 @@ There is an exported docker volume of /var/lib/mysql to allow persistence of tha
27 27
 
28 28
 Additionally, the database variables may be overridden from the above as per the standard Huginn documentation:
29 29
 
30
-    HUGINN_DATABASE_ADAPTER #(must be either 'postgres' or 'mysql2')
31
-    HUGINN_DATABASE_HOST
32
-    HUGINN_DATABASE_PORT
30
+    DATABASE_ADAPTER #(must be either 'postgres' or 'mysql2')
31
+    DATABASE_HOST
32
+    DATABASE_PORT
33 33
 
34 34
 This script will run database migrations (rake db:migrate) which should be idempotent.
35 35
 
@@ -70,8 +70,6 @@ To link to another container named 'postgres':
70 70
     docker run --name huginn_postgres \
71 71
         -e POSTGRES_PASSWORD=mysecretpassword \
72 72
         -e POSTGRES_USER=huginn -d postgres
73
-    docker run -it --link huginn_postgres:postgres --rm postgres \
74
-        sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U huginn -c "create database huginn_development;"'
75 73
     docker run --rm --name huginn \
76 74
         --link huginn_postgres:postgres \
77 75
         -p 3000:3000 \
@@ -80,60 +78,13 @@ To link to another container named 'postgres':
80 78
         -e HUGINN_DATABASE_ADAPTER=postgresql \
81 79
         cantino/huginn
82 80
 
83
-The `docker/` folder also has a `docker-compose.yml` that allows for a sample database formation with a data volume container:
81
+The `docker/multi-process` folder also has a `docker-compose.yml` that allows for a sample database formation with a data volume container:
84 82
 
85
-    cd docker ; docker-compose up
83
+    cd docker/multi-process ; docker-compose up
86 84
 
87 85
 ## Environment Variables
88 86
 
89
-Other Huginn 12factored environment variables of note, as generated and put into the .env file as per Huginn documentation,
90
-with an additional `HUGINN_` prefix to the variable.
91
-
92
-These are:
93
-
94
-    HUGINN_APP_SECRET_TOKEN
95
-    HUGINN_DOMAIN
96
-    HUGINN_ASSET_HOST
97
-    HUGINN_DATABASE_ADAPTER
98
-    HUGINN_DATABASE_ENCODING
99
-    HUGINN_DATABASE_RECONNECT
100
-    HUGINN_DATABASE_NAME
101
-    HUGINN_DATABASE_POOL
102
-    HUGINN_DATABASE_USERNAME
103
-    HUGINN_DATABASE_PASSWORD
104
-    HUGINN_DATABASE_HOST
105
-    HUGINN_DATABASE_PORT
106
-    HUGINN_DATABASE_SOCKET
107
-    HUGINN_RAILS_ENV
108
-    HUGINN_FORCE_SSL
109
-    HUGINN_INVITATION_CODE
110
-    HUGINN_SMTP_DOMAIN
111
-    HUGINN_SMTP_USER_NAME
112
-    HUGINN_SMTP_PASSWORD
113
-    HUGINN_SMTP_SERVER
114
-    HUGINN_SMTP_PORT
115
-    HUGINN_SMTP_AUTHENTICATION
116
-    HUGINN_SMTP_ENABLE_STARTTLS_AUTO
117
-    HUGINN_EMAIL_FROM_ADDRESS
118
-    HUGINN_AGENT_LOG_LENGTH
119
-    HUGINN_TWITTER_OAUTH_KEY
120
-    HUGINN_TWITTER_OAUTH_SECRET
121
-    HUGINN_THIRTY_SEVEN_SIGNALS_OAUTH_KEY
122
-    HUGINN_THIRTY_SEVEN_SIGNALS_OAUTH_SECRET
123
-    HUGINN_AWS_ACCESS_KEY_ID
124
-    HUGINN_AWS_ACCESS_KEY
125
-    HUGINN_AWS_SANDBOX
126
-    HUGINN_FARADAY_HTTP_BACKEND
127
-    HUGINN_DEFAULT_HTTP_USER_AGENT
128
-    HUGINN_ALLOW_JSONPATH_EVAL
129
-    HUGINN_ENABLE_INSECURE_AGENTS
130
-    HUGGIN_ENABLE_SECOND_PRECISION_SCHEDULE
131
-    HUGINN_USE_GRAPHVIZ_DOT
132
-    HUGINN_TIMEZONE
133
-    HUGGIN_FAILED_JOBS_TO_KEEP
134
-
135
-
136
-The above environment variables will override the defaults. The defaults are read from the [.env.example](https://github.com/cantino/huginn/blob/master/.env.example) file.
87
+Other Huginn 12factored environment variables of note, as generated and put into the .env file as per Huginn documentation. All variables of the [.env.example](https://github.com/cantino/huginn/blob/master/.env.example) can be used to override the defaults which a read from the current `.env.example`.
137 88
 
138 89
 For variables in the .env.example that are commented out, the default is to not include that variable in the generated .env file.
139 90
 
@@ -145,7 +96,7 @@ You don't need to do this on your own, because there is an [automated build](htt
145 96
 
146 97
 ## Source
147 98
 
148
-The source is [available on GitHub](https://github.com/cantino/huginn/).
99
+The source is [available on GitHub](https://github.com/cantino/huginn/docker/multi-process/).
149 100
 
150 101
 Please feel free to submit pull requests and/or fork at your leisure.
151 102
 

+ 14 - 11
docker/multi-process/scripts/init

@@ -22,11 +22,16 @@ elif [ -n "${POSTGRES_PORT_5432_TCP_ADDR}" ]; then
22 22
   DATABASE_PORT=${DATABASE_PORT:-${POSTGRES_PORT_5432_TCP_PORT}}
23 23
   DATABASE_ENCODING=utf8
24 24
 else
25
-  DATABASE_PASSWORD=password
26
-  DATABASE_NAME=huginn_production
25
+  START_MYSQL=${START_MYSQL:-true}
27 26
 fi
28 27
 
29
-USE_GRAPHVIZ_DOT=${USE_GRAPHVIZ_DOT:-${USE_GRAPHVIZ_DOT:-dot}}
28
+USE_GRAPHVIZ_DOT=${HUGINN_USE_GRAPHVIZ_DOT:-${USE_GRAPHVIZ_DOT:-dot}}
29
+DATABASE_HOST=${HUGINN_DATABASE_HOST:-${DATABASE_HOST:-localhost}}
30
+DATABASE_PORT=${HUGINN_DATABASE_PORT:-${DATABASE_PORT}}
31
+DATABASE_ENCODING=${HUGINN_DATABASE_ENCODING:-${DATABASE_ENCODING}}
32
+DATABASE_PASSWORD=${HUGINN_DATABASE_PASSWORD:-${DATABASE_PASSWORD:-password}}
33
+DATABASE_NAME=${HUGINN_DATABASE_NAME:-${DATABASE_NAME:-huginn_production}}
34
+RAILS_ENV=${HUGINN_RAILS_ENV:-${RAILS_ENV:-production}}
30 35
 
31 36
 IFS="="
32 37
 grep = /app/.env.example | sed -e 's/^#\([^ ]\)/\1/' | grep -v -e '^#' | \
@@ -34,17 +39,15 @@ grep = /app/.env.example | sed -e 's/^#\([^ ]\)/\1/' | grep -v -e '^#' | \
34 39
     eval "echo \"$var=\${$var:-\${HUGINN_$var-\$value}}\""
35 40
   done | grep -v -e ^= > /app/.env
36 41
 
37
-eval "echo RAILS_ENV=${RAILS_ENV:-${RAILS_ENV:-production}}" >> .env
38
-eval "echo ON_HEROKU=true" >> .env
39
-eval "echo RAILS_SERVE_STATIC_FILES=true" >> .env
42
+eval "echo RAILS_ENV=${RAILS_ENV}" >> .env
43
+eval "echo START_MYSQL=${START_MYSQL}" >> .env
44
+echo "ON_HEROKU=true" >> .env
45
+echo "RAILS_SERVE_STATIC_FILES=true" >> .env
40 46
 
41 47
 chmod ugo+r /app/.env
42 48
 source /app/.env
43 49
 sudo -u huginn -H bundle install --deployment --without test
44 50
 
45
-DATABASE_HOST=${HUGINN_DATABASE_HOST:-${DATABASE_HOST:-localhost}}
46
-DATABASE_ENCODING=${HUGINN_DATABASE_ENCODING:-${DATABASE_ENCODING}}
47
-
48 51
 # use default port number if it is still not set
49 52
 case "${DATABASE_ADAPTER}" in
50 53
   mysql2) DATABASE_PORT=${DATABASE_PORT:-3306} ;;
@@ -79,7 +82,8 @@ source /app/.env
79 82
 echo DATABASE_HOST=\${DATABASE_HOST}
80 83
 
81 84
 # start mysql server if \${DATABASE_HOST} is the .env.example default
82
-if [ "\${DATABASE_HOST}" = "your-domain-here.com" -o "\${DATABASE_HOST}" = "" ]; then
85
+if [ "\${START_MYSQL}" = "true" ]; then
86
+  echo "DATABASE_SOCKET=/var/run/mysqld/mysqld.sock" >> .env
83 87
   if [ "\${DATABASE_ADAPTER}" = "postgresql" ]; then
84 88
     echo "DATABASE_ADAPTER 'postgresql' is not supported internally. Please provide DATABASE_HOST."
85 89
     exit 1
@@ -126,7 +130,6 @@ EOF
126 130
   done
127 131
 
128 132
   if ! echo "USE \${DATABASE_NAME}" | mysql -u\${DATABASE_USERNAME:-root} \${DATABASE_PASSWORD:+-p\$DATABASE_PASSWORD} >/dev/null 2>&1; then
129
-    DB_INIT="yes"
130 133
     echo "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('\${DATABASE_PASSWORD:\$DATABASE_PASSWORD}');" | mysql -u root
131 134
   fi
132 135
 fi

+ 0 - 38
docker/multi-process/scripts/setup

@@ -1,38 +0,0 @@
1
-#!/bin/bash
2
-set -e
3
-
4
-locale-gen en_US.UTF-8
5
-
6
-# Shallow clone the huginn project repo
7
-git clone --depth 1 https://github.com/cantino/huginn /app
8
-
9
-cd /app
10
-
11
-# add a huginn group and user
12
-adduser --group huginn
13
-adduser --disabled-login --ingroup huginn --gecos 'Huginn' --no-create-home --home /app huginn
14
-adduser huginn sudo
15
-passwd -d huginn
16
-
17
-# Change the ownership to huginn
18
-chown -R huginn:huginn /app
19
-
20
-# create required tmp and log directories
21
-sudo -u huginn -H mkdir -p tmp/pids tmp/cache tmp/sockets log
22
-chmod -R u+rwX log tmp
23
-
24
-# install gems required by Huginn, use local cache if available
25
-if [ -d "/scripts/cache" ]; then
26
-  mv /scripts/cache vendor/
27
-  chown -R huginn:huginn vendor/cache
28
-fi
29
-sudo -u huginn -H cp .env.example .env
30
-sudo -u huginn -H LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" ON_HEROKU=true bundle install --deployment --without test
31
-sudo -u huginn -H rm .env
32
-
33
-# silence setlocale message (THANKS DEBIAN!)
34
-cat > /etc/default/locale <<EOF
35
-LC_ALL=en_US.UTF-8
36
-LANG=en_US.UTF-8
37
-EOF
38
-

+ 35 - 0
docker/single-process/develop.yml

@@ -0,0 +1,35 @@
1
+mysqldata:
2
+  image: mysql
3
+  command: /bin/true
4
+
5
+mysql:
6
+  image: mysql
7
+  volumes_from:
8
+    - mysqldata
9
+  environment:
10
+    MYSQL_ROOT_PASSWORD: myrootpassword
11
+    MYSQL_DATABASE: huginn
12
+    MYSQL_USER: huginn
13
+    MYSQL_PASSWORD: myhuginnpassword
14
+
15
+huginn_web:
16
+  build: .
17
+  restart: always
18
+  extends:
19
+    file: environment.yml
20
+    service: huginn_base
21
+  ports:
22
+    - 3000:3000
23
+  links:
24
+    - mysql
25
+
26
+huginn_threaded:
27
+  build: .
28
+  restart: always
29
+  extends:
30
+    file: environment.yml
31
+    service: huginn_base
32
+  links:
33
+    - mysql
34
+  command: /scripts/init bin/threaded.rb
35
+

+ 2 - 2
docker/single-process/docker-compose.yml

@@ -13,7 +13,7 @@ mysql:
13 13
     MYSQL_PASSWORD: myhuginnpassword
14 14
 
15 15
 huginn_web:
16
-  build: .
16
+  image: dsander/huginn-single-process
17 17
   restart: always
18 18
   extends:
19 19
     file: environment.yml
@@ -24,7 +24,7 @@ huginn_web:
24 24
     - mysql
25 25
 
26 26
 huginn_threaded:
27
-  build: .
27
+  image: dsander/huginn-single-process
28 28
   restart: always
29 29
   extends:
30 30
     file: environment.yml

+ 5 - 5
docker/single-process/postgresql.yml

@@ -11,7 +11,7 @@ postgres:
11 11
     POSTGRES_USER: huginn
12 12
 
13 13
 huginn_web:
14
-  build: .
14
+  image: dsander/huginn-single-process
15 15
   restart: always
16 16
   extends:
17 17
     file: environment.yml
@@ -24,7 +24,7 @@ huginn_web:
24 24
     - postgres
25 25
 
26 26
 huginn_threaded:
27
-  build: .
27
+  image: dsander/huginn-single-process
28 28
   restart: always
29 29
   extends:
30 30
     file: environment.yml
@@ -36,7 +36,7 @@ huginn_threaded:
36 36
   command: /scripts/init bin/threaded.rb
37 37
 
38 38
 # huginn_schedule:
39
-#   build: .
39
+#   image: dsander/huginn-single-process
40 40
 #   extends:
41 41
 #     file: environment.yml
42 42
 #     service: huginn_base
@@ -48,7 +48,7 @@ huginn_threaded:
48 48
 
49 49
 
50 50
 # huginn_twitter_stream:
51
-#   build: .
51
+#   image: dsander/huginn-single-process
52 52
 #   extends:
53 53
 #     file: environment.yml
54 54
 #     service: huginn_base
@@ -60,7 +60,7 @@ huginn_threaded:
60 60
 
61 61
 
62 62
 # huginn_dj1:
63
-#   build: .
63
+#   image: dsander/huginn-single-process
64 64
 #   extends:
65 65
 #     file: environment.yml
66 66
 #     service: huginn_base