diff options
author | 2021-11-16 03:11:29 -0500 | |
---|---|---|
committer | 2021-11-16 03:11:29 -0500 | |
commit | 7962660cc2c07e6c3bfa74faf7d8ba429546ea73 (patch) | |
tree | ff385e1590b875bf4799f275b393bc9053d94e02 /docker | |
parent | Update entrypoint.sh (diff) | |
parent | Merge branch 'master' into master (diff) | |
download | ferdium-server-7962660cc2c07e6c3bfa74faf7d8ba429546ea73.tar.gz ferdium-server-7962660cc2c07e6c3bfa74faf7d8ba429546ea73.tar.zst ferdium-server-7962660cc2c07e6c3bfa74faf7d8ba429546ea73.zip |
Merge pull request #2 from getferdi/master
Update to head
Diffstat (limited to 'docker')
-rw-r--r-- | docker/.gitignore | 1 | ||||
-rw-r--r-- | docker/README.md | 50 | ||||
-rwxr-xr-x | docker/entrypoint.sh | 35 |
3 files changed, 46 insertions, 40 deletions
diff --git a/docker/.gitignore b/docker/.gitignore new file mode 100644 index 0000000..7376571 --- /dev/null +++ b/docker/.gitignore | |||
@@ -0,0 +1 @@ | |||
docker-compose.override.yml | |||
diff --git a/docker/README.md b/docker/README.md index 3d8bd5f..7581bef 100644 --- a/docker/README.md +++ b/docker/README.md | |||
@@ -1,5 +1,5 @@ | |||
1 | # Ferdi-server-docker | 1 | # Ferdi-server-docker |
2 | [Ferdi](https://github.com/getferdi/ferdi) is a hard-fork of [Franz](https://github.com/meetfranz/franz), adding awesome features and removing unwanted ones. Ferdi-server is an unofficial replacement of the Franz server for use with the Ferdi Client. | 2 | [Ferdi](https://github.com/getferdi/ferdi) is a hard-fork of [Franz](https://github.com/meetfranz/franz), adding awesome features and removing unwanted ones. Ferdi-server is an unofficial replacement of the Franz server for use with the Ferdi Client. |
3 | 3 | ||
4 | This is a dockerized version of [Ferdi-server](https://github.com/getferdi/server) running on Alpine Linux and Node.js (v10.16.3). | 4 | This is a dockerized version of [Ferdi-server](https://github.com/getferdi/server) running on Alpine Linux and Node.js (v10.16.3). |
5 | 5 | ||
@@ -35,7 +35,7 @@ To create the docker container with the proper parameters: | |||
35 | docker create \ | 35 | docker create \ |
36 | --name=ferdi-server \ | 36 | --name=ferdi-server \ |
37 | -e NODE_ENV=development \ | 37 | -e NODE_ENV=development \ |
38 | -e EXTERNAL_DOMAIN=<ferdi-serverdomain> \ | 38 | -e EXTERNAL_DOMAIN=<ferdi-serverdomain> \ |
39 | -e DB_CONNECTION=<database> \ | 39 | -e DB_CONNECTION=<database> \ |
40 | -e DB_HOST=<yourdbhost> \ | 40 | -e DB_HOST=<yourdbhost> \ |
41 | -e DB_PORT=<yourdbport> \ | 41 | -e DB_PORT=<yourdbport> \ |
@@ -65,15 +65,15 @@ To create the docker container with the proper parameters: | |||
65 | 65 | ||
66 | You can use the provided sample [docker-compose.yml](https://github.com/getferdi/server/tree/master/docker/docker-compose.yml) if you are happy with the default environmental variables. This will pull the latest image from Docker Hub or use a local copy of the image which you can build using the instructions provided in the [Building locally section](#building-locally). | 66 | You can use the provided sample [docker-compose.yml](https://github.com/getferdi/server/tree/master/docker/docker-compose.yml) if you are happy with the default environmental variables. This will pull the latest image from Docker Hub or use a local copy of the image which you can build using the instructions provided in the [Building locally section](#building-locally). |
67 | 67 | ||
68 | To start the application, use `docker-compose up -d`. | 68 | To start the application, use `docker-compose -f docker/docker-compose.yml up -d`. |
69 | The server will be launched at [http://localhost:3333/](http://localhost:3333/) address. | 69 | The server will be launched at [http://localhost:3333/](http://localhost:3333/) address. |
70 | 70 | ||
71 | ## Configuration | 71 | ## Configuration |
72 | 72 | ||
73 | Container images are configured using parameters passed at runtime (such as those above). An explanaition of the default parameters is included below, but please see [the Docker documentation](https://docs.docker.com/get-started/overview/) for additional information. | 73 | Container images are configured using parameters passed at runtime (such as those above). An explanaition of the default parameters is included below, but please see [the Docker documentation](https://docs.docker.com/get-started/overview/) for additional information. |
74 | 74 | ||
75 | <strike>If any environmental parameter is not passed to the container, its value will be taken from the `/config/config.txt` file.</strike> | 75 | <strike>If any environmental parameter is not passed to the container, its value will be taken from the `/config/config.txt` file.</strike> |
76 | **Warning, the use of `config.txt` is now deprecated. Please make sure to pass the correct environmental variables to your container at runtime. ** | 76 | **Warning, the use of `config.txt` is now deprecated. Please make sure to pass the correct environmental variables to your container at runtime. ** |
77 | 77 | ||
78 | | Parameter | Function | | 78 | | Parameter | Function | |
79 | | :----: | --- | | 79 | | :----: | --- | |
@@ -108,7 +108,7 @@ By enabling the `CONNECT_WITH_FRANZ` option, Ferdi-server can: | |||
108 | 108 | ||
109 | ## Supported databases and drivers | 109 | ## Supported databases and drivers |
110 | 110 | ||
111 | To use a different database than the default, SQLite3, enter the driver code below in your ENV configuration. | 111 | To use a different database than the default, SQLite3, enter the driver code below in your ENV configuration. |
112 | 112 | ||
113 | | Database | Driver | | 113 | | Database | Driver | |
114 | | :----: | --- | | 114 | | :----: | --- | |
@@ -150,7 +150,7 @@ If you are an existing Ferdi-server user who usees an external database or diffe | |||
150 | | `-v <path to recipes>:/app/recipes` | this will strore Ferdi-server's recipes on the docker host for persistence | | 150 | | `-v <path to recipes>:/app/recipes` | this will strore Ferdi-server's recipes on the docker host for persistence | |
151 | 151 | ||
152 | **In eithr case, pleasee be sure to pass the correct variables to the new Ferdi-server container in order maintain access to your existing database.** | 152 | **In eithr case, pleasee be sure to pass the correct variables to the new Ferdi-server container in order maintain access to your existing database.** |
153 | 153 | ||
154 | ## NGINX config block | 154 | ## NGINX config block |
155 | 155 | ||
156 | To access Ferdi-server from outside of your home network on a subdomain use this server block: | 156 | To access Ferdi-server from outside of your home network on a subdomain use this server block: |
@@ -158,19 +158,19 @@ To access Ferdi-server from outside of your home network on a subdomain use this | |||
158 | ``` | 158 | ``` |
159 | # Ferdi-server | 159 | # Ferdi-server |
160 | server { | 160 | server { |
161 | listen 443 ssl http2; | 161 | listen 443 ssl http2; |
162 | server_name ferdi.my.website; | 162 | server_name ferdi.my.website; |
163 | 163 | ||
164 | # all ssl related config moved to ssl.conf | 164 | # all ssl related config moved to ssl.conf |
165 | include /config/nginx/ssl.conf; | 165 | include /config/nginx/ssl.conf; |
166 | 166 | ||
167 | location / { | 167 | location / { |
168 | proxy_pass http://<Ferdi-IP>:3333; | 168 | proxy_pass http://<Ferdi-IP>:3333; |
169 | proxy_set_header X-Real-IP $remote_addr; | 169 | proxy_set_header X-Real-IP $remote_addr; |
170 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | 170 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
171 | proxy_set_header Host $host; | 171 | proxy_set_header Host $host; |
172 | proxy_set_header X-Forwarded-Proto $scheme; | 172 | proxy_set_header X-Forwarded-Proto $scheme; |
173 | } | 173 | } |
174 | } | 174 | } |
175 | ``` | 175 | ``` |
176 | 176 | ||
@@ -217,15 +217,13 @@ Below are the instructions for updating the container to get the most recent ver | |||
217 | * Delete the container: `docker rm ferdi-server` | 217 | * Delete the container: `docker rm ferdi-server` |
218 | * Recreate a new container with the same docker create parameters as instructed above (if mapped correctly to a host folder, your `/config` folder and ENV settings will be preserved) | 218 | * Recreate a new container with the same docker create parameters as instructed above (if mapped correctly to a host folder, your `/config` folder and ENV settings will be preserved) |
219 | * Start the new container: `docker start ferdi-server` | 219 | * Start the new container: `docker start ferdi-server` |
220 | * You can also remove the old dangling images: `docker image prune` | ||
221 | 220 | ||
222 | ### Via Docker Compose | 221 | ### Via Docker Compose |
223 | 222 | ||
224 | * Update all images: `docker-compose pull` | 223 | * Update all images: `docker-compose -f docker/docker-compose.yml pull` |
225 | * or update a single image: `docker-compose pull ferdi-server` | 224 | * or update a single image: `docker-compose -f docker/docker-compose.yml pull ferdi-server` |
226 | * Let compose update all containers as necessary: `docker-compose up -d` | 225 | * Let compose update all containers as necessary: `docker-compose -f docker/docker-compose.yml up -d` |
227 | * or update a single container: `docker-compose up -d ferdi-server` | 226 | * or update a single container: `docker-compose -f docker/docker-compose.yml up -d ferdi-server` |
228 | * You can also remove the old dangling images: `docker image prune` | ||
229 | 227 | ||
230 | ## Building locally | 228 | ## Building locally |
231 | 229 | ||
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 2d1fd89..2e58abc 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh | |||
@@ -1,6 +1,6 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | echo << EOL | 3 | cat << EOL |
4 | ------------------------------------- | 4 | ------------------------------------- |
5 | ____ ___ | 5 | ____ ___ |
6 | / __/__ _______/ (_) | 6 | / __/__ _______/ (_) |
@@ -14,24 +14,31 @@ Support our Open Collective at: | |||
14 | https://opencollective.com/getferdi/ | 14 | https://opencollective.com/getferdi/ |
15 | EOL | 15 | EOL |
16 | 16 | ||
17 | key_file="${DATA_DIR}/FERDI_APP_KEY.txt" | ||
18 | |||
19 | print_app_key_message() { | ||
20 | app_key=$1 | ||
21 | printf '**** App key is %s. ' ${app_key} | ||
22 | printf 'You can modify `%s` to update the app key ****\n' ${key_file} | ||
23 | } | ||
24 | |||
17 | # Create APP key if needed | 25 | # Create APP key if needed |
18 | if [[ -f "${DATA_DIR}/FERDI_APP_KEY.txt" ]]; then | 26 | if [ -z ${APP_KEY} ] && [ ! -f ${key_file} ] |
19 | echo " " | 27 | then |
20 | echo "**** App Key found ****" | 28 | echo '**** Generating Ferdi-server app key for first run ****' |
21 | APP_KEY=$(cat /data/FERDI_APP_KEY.txt) | 29 | adonis key:generate |
22 | echo "**** App Key set to $APP_KEY you can modify FERDI_APP_KEY.txt to update your key ****" | 30 | APP_KEY=$(grep APP_KEY .env | cut -d '=' -f2) |
23 | elif [[ -z "${APP_KEY}" ]]; then | 31 | echo ${APP_KEY} > ${key_file} |
24 | echo "**** Generating Ferdi-server app key for first run ****" | 32 | print_app_key_message ${APP_KEY} |
25 | adonis key:generate | 33 | else |
26 | APP_KEY=$(grep APP_KEY .env | cut -d '=' -f2) | 34 | APP_KEY=$(cat ${key_file}) |
27 | echo "${APP_KEY}" > "${DATA_DIR}/FERDI_APP_KEY.txt" | 35 | print_app_key_message ${APP_KEY} |
28 | echo "**** App Key set to $APP_KEY you can modify FERDI_APP_KEY.txt to update your key ****" | ||
29 | fi | 36 | fi |
30 | 37 | ||
31 | export APP_KEY | 38 | export APP_KEY |
32 | 39 | ||
33 | node ace migration:run --force | 40 | node ace migration:run --force |
34 | 41 | ||
35 | chown -R ${PUID:-1000}:${PGID:-1000} $DATA_DIR /app | 42 | chown -R "${PUID:-1000}":"${PGID:-1000}" "${DATA_DIR}" /app |
36 | 43 | ||
37 | su-exec ${PUID:-1000}:${PGID:-1000} node server.js | 44 | su-exec "${PUID:-1000}":"${PGID:-1000}" node server.js |