From 7e55e4bf83321c770645e9657589a620335fa029 Mon Sep 17 00:00:00 2001 From: Michal Kostewicz Date: Fri, 5 Feb 2021 20:43:13 +0100 Subject: Modifying Dockerfile so that it can use the current application code to build the image. Update instructions for building image in README.md --- .dockerignore | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .dockerignore (limited to '.dockerignore') diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..43c6cd0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,21 @@ +.DS_Store + +# ignore .git and .cache folders +.git +.gitignore +.github +.gitattributes +.cache + +# ignore all markdown files (md) beside all README*.md other than README-secret.md +*.md +!README*.md +README-secret.md + +# ignore other directories +docker +!docker/root +node_modules + + + -- cgit v1.2.3-54-g00ecf From 7329a7fd852082f0216b4f67f1912eaa601981fc Mon Sep 17 00:00:00 2001 From: Michal Kostewicz Date: Sun, 7 Feb 2021 12:43:41 +0100 Subject: Add new configuration for docker with small script to generate or use APP_KEY. docker-compose was adjusted to use DATA_DIR. --- .dockerignore | 2 +- docker/Dockerfile | 109 ++++------------- docker/docker-compose.yml | 5 +- docker/entrypoint.sh | 40 +++++++ docker/root/defaults/.env.example | 35 ------ docker/root/etc/cont-init.d/10-adduser | 32 ----- docker/root/etc/cont-init.d/50-config | 174 ---------------------------- docker/root/etc/services.d/ferdi-server/run | 10 -- 8 files changed, 64 insertions(+), 343 deletions(-) create mode 100755 docker/entrypoint.sh delete mode 100755 docker/root/defaults/.env.example delete mode 100755 docker/root/etc/cont-init.d/10-adduser delete mode 100755 docker/root/etc/cont-init.d/50-config delete mode 100755 docker/root/etc/services.d/ferdi-server/run (limited to '.dockerignore') diff --git a/.dockerignore b/.dockerignore index 43c6cd0..7dad3a9 100644 --- a/.dockerignore +++ b/.dockerignore @@ -14,7 +14,7 @@ README-secret.md # ignore other directories docker -!docker/root +!docker/entrypoint.sh node_modules diff --git a/docker/Dockerfile b/docker/Dockerfile index a561509..799bb0b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,96 +1,27 @@ -FROM lsiobase/alpine:3.11 +FROM node:lts-alpine as build -# version labels -ARG BUILD_DATE -LABEL build_version="Ferdi-server-docker Build-date:- ${BUILD_DATE}" +WORKDIR /server-build + +RUN ["apk", "add", "--no-cache", "python", "make", "gcc", "g++", "libc-dev", "sqlite-dev"] + +COPY . /server-build + +RUN ["npm", "ci", "--production", "--build-from-source", "--sqlite=/usr/local"] + +FROM node:lts-alpine + +WORKDIR /app LABEL maintainer="xthursdayx" -ARG FERDI_RELEASE -ENV NODE_VERSION=10.16.3 -ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2 +ENV HOST=0.0.0.0 PORT=3333 -# install packages -RUN \ - echo "**** installing build packages ****" && \ - apk add --no-cache \ - libcap \ - libstdc++ \ - nano && \ - apk add --no-cache --virtual .build-deps \ - binutils-gold \ - curl \ - gnupg \ - gcc \ - g++ \ - linux-headers \ - make \ - memcached \ - python && \ - echo "**** downloading keys ****" && \ - # gpg keys listed at https://github.com/nodejs/node#release-keys - for key in \ - 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ - FD3A5288F042B6850C66B31F09FE44734EB7990E \ - 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ - DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ - C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ - B9AE9905FFD7803F25714661B63B535A4C206CA9 \ - 77984A986EBC2AA786BC0F66B01FBB92821C587A \ - 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \ - 4ED778F539E3634C779C87C6D7062848A1AB005C \ - A48C2BEE680E841632CD4E44F07496B3EB3C1762 \ - B9E2F5981AA6E0CD28160D9FF13993A75599653C \ - ; do \ - gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \ - gpg --batch --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \ - gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \ - done && \ - echo "**** installing node ****" && \ - curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" && \ - curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" && \ - gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc && \ - grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - && \ - tar -xf "node-v$NODE_VERSION.tar.xz" && \ - cd "node-v$NODE_VERSION" && \ - ./configure --prefix=/usr && \ - make -j$(getconf _NPROCESSORS_ONLN) V= && \ - make install && \ - apk del .build-deps && \ - cd / && \ - rm -Rf "node-v$NODE_VERSION" && \ - rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt +RUN ["apk", "add", "--no-cache", "sqlite-libs", "curl"] -COPY . /app - -RUN \ - apk add --no-cache --virtual .build-deps-ferdi \ - curl \ - gnupg \ - tar && \ - echo "**** installing npm ****" && \ - npm config set unsafe-perm true && \ - npm install -g npm@latest && \ - find /usr/lib/node_modules/npm -name test -o -name .bin -type d | xargs rm -rf && \ - echo "**** cleanup ****" && \ - apk del .build-deps-ferdi && \ - rm -rf \ - ${RM_DIRS} \ - /SHASUMS256.txt \ - /tmp/* \ - /var/cache/apk/* \ - /usr/share/man/* \ - /usr/share/doc \ - /root/.node-gyp \ - /root/.config \ - /usr/lib/node_modules/npm/man \ - /usr/lib/node_modules/npm/doc \ - /usr/lib/node_modules/npm/html \ - /usr/lib/node_modules/npm/scripts - -COPY docker/root/ / +COPY --from=build /server-build /app +RUN ["touch", ".env"] +RUN ["npm", "i", "-g", "@adonisjs/cli"] -USER root +HEALTHCHECK --interval=5m --timeout=3s CMD curl -sSf http://localhost:${PORT}/health -# ports and volumes -EXPOSE 80 443 -VOLUME /app/database /app/recipes /config +COPY docker/entrypoint.sh /entrypoint.sh +CMD ["/entrypoint.sh"] \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 7bf1b8c..364f9c3 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -24,12 +24,13 @@ services: - IS_DASHBOARD_ENABLED=true - IS_REGISTRATION_ENABLED=true - CONNECT_WITH_FRANZ=false + - DATA_DIR=/database volumes: - ferdi-config-vol:/config - - ferdi-database-vol:/app/database + - ferdi-database-vol:/database - ferdi-recipes-vol:/app/recipes ports: - - 3333:80 + - 3333:3333 restart: unless-stopped volumes: ferdi-config-vol: diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 0000000..cb0dd0f --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +echo << EOL +------------------------------------- + ____ ___ + / __/__ _______/ (_) + / _// -_) __/ _ / / + _/_/ \__/_/ \_,_/_/ + / __/__ _____ _____ ____ + _\ \/ -_) __/ |/ / -_) __/ + /___/\__/_/ |___/\__/_/ +Brought to you by getferdi.com +Support our Open Collective at: +https://opencollective.com/getferdi/ +EOL + +# Create APP key if needed +if [ ! -f "/config/FERDI_APP_KEY.txt" ]; + then + echo " " + echo "**** Generating Ferdi-server app key for first run ****" + adonis key:generate + source .env + echo $APP_KEY > /config/FERDI_APP_KEY.txt + echo "**** App Key set to $APP_KEY you can modify FERDI_APP_KEY.txt to update your key ****" + sed -i "s/APP_KEY=/APP_KEY=$APP_KEY/g" /config/config.txt +elif [ -f "/config/FERDI_APP_KEY.txt" ]; + then + echo " " + echo "**** App Key found ****" + APP_KEY=$(cat /config/FERDI_APP_KEY.txt) + sed -i "s/APP_KEY=.*/APP_KEY=$APP_KEY/g" /config/config.txt + echo "**** App Key set to $APP_KEY you can modify FERDI_APP_KEY.txt to update your key ****" +fi + +export APP_KEY=$APP_KEY + +node ace migration:run --force + +exec node server.js diff --git a/docker/root/defaults/.env.example b/docker/root/defaults/.env.example deleted file mode 100755 index 2ed73dc..0000000 --- a/docker/root/defaults/.env.example +++ /dev/null @@ -1,35 +0,0 @@ -HOST=0.0.0.0 -PORT=80 -NODE_ENV=development - -APP_NAME=AdonisJs -APP_URL=http://${EXTERNAL_DOMAIN} -EXTERNAL_DOMAIN=ferdi.domain.tld - -CACHE_VIEWS=false - -APP_KEY=appkey - -DB_CONNECTION=sqlite -DB_HOST=127.0.0.1 -DB_PORT=3306 -DB_USER=root -DB_PASSWORD=password -DB_DATABASE=adonis - -DB_SSL=false - -HASH_DRIVER=bcrypt - -IS_CREATION_ENABLED=true -IS_DASHBOARD_ENABLED=true -IS_REGISTRATION_ENABLED=true -CONNECT_WITH_FRANZ=true - -MAIL_CONNECTION=smtp -SMTP_PORT=2525 -SMTP_HOST=127.0.0.1 -MAIL_USERNAME=username -MAIL_PASSWORD=password -MAIL_SENDER=noreply@getferdi.com -MAIL_SSL=false diff --git a/docker/root/etc/cont-init.d/10-adduser b/docker/root/etc/cont-init.d/10-adduser deleted file mode 100755 index 8ba1aea..0000000 --- a/docker/root/etc/cont-init.d/10-adduser +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/with-contenv bash - -PUID=${PUID:-911} -PGID=${PGID:-911} - -groupmod -o -g "$PGID" abc -usermod -o -u "$PUID" abc - -echo ' -------------------------------------- - ____ ___ - / __/__ _______/ (_) - / _// -_) __/ _ / / - _/_/ \__/_/ \_,_/_/ - / __/__ _____ _____ ____ - _\ \/ -_) __/ |/ / -_) __/ - /___/\__/_/ |___/\__/_/ - -Brought to you by getferdi.com -Support our Open Collective at: -https://opencollective.com/getferdi/ -------------------------------------- -GID/UID --------------------------------------' -echo " -User uid: $(id -u abc) -User gid: $(id -g abc) -------------------------------------- -" -chown abc:abc /app -chown abc:abc /config -chown abc:abc /defaults \ No newline at end of file diff --git a/docker/root/etc/cont-init.d/50-config b/docker/root/etc/cont-init.d/50-config deleted file mode 100755 index 72b2d00..0000000 --- a/docker/root/etc/cont-init.d/50-config +++ /dev/null @@ -1,174 +0,0 @@ -#!/usr/bin/with-contenv bash - -# Display variables for troubleshooting -echo " " -echo "-------------------------------------" -echo " " -echo -e "Variables set:\\n\ -NODE_ENV=${NODE_ENV}\\n\ -EXTERNAL_DOMAIN=${EXTERNAL_DOMAIN}\\n\ -DB_CONNECTION=${DB_CONNECTION}\\n\ -DB_HOST=${DB_HOST}\\n\ -DB_PORT=${DB_PORT}\\n\ -DB_USER=${DB_USER}\\n\ -DB_PASSWORD=${DB_PASSWORD}\\n\ -DB_DATABASE=${DB_DATABASE}\\n\ -DB_SSL=${DB_SSL}\\n\ -IS_CREATION_ENABLED=${IS_CREATION_ENABLED}\\n\ -IS_DASHBOARD_ENABLED=${IS_DASHBOARD_ENABLED}\\n\ -IS_REGISTRATION_ENABLED=${IS_REGISTRATION_ENABLED}\\n\ -CONNECT_WITH_FRANZ=${CONNECT_WITH_FRANZ}\\n\ -MAIL_CONNECTION=${MAIL_CONNECTION}\\n\ -SMTP_PORT=${SMTP_PORT}\\n\ -SMTP_HOST=${SMTP_HOST}\\n\ -MAIL_SSL=${MAIL_SSL}\\n\ -MAIL_USERNAME=${MAIL_USERNAME}\\n\ -MAIL_PASSWORD=${MAIL_PASSWORD}\\n\ -MAIL_SENDER=${MAIL_SENDER}\\n" - -# Echo init finish for test runs -if [ -n "${TEST_RUN}" ]; then - echo " " - echo '**** [services.d] done ****' -fi - -# set ferdi-server status -echo " " -echo "**** Checking Ferdi-server settings ****" -if [ -f /config/config.txt ]; then - [[ "${NODE_ENV}" ]] && sed -i "s/NODE_ENV=.*/NODE_ENV=${NODE_ENV}/g" /config/config.txt - [[ "${EXTERNAL_DOMAIN}" ]] && sed -i "s/EXTERNAL_DOMAIN=.*/EXTERNAL_DOMAIN=${EXTERNAL_DOMAIN}/g" /config/config.txt - [[ "${IS_CREATION_ENABLED}" ]] && sed -i "s/IS_CREATION_ENABLED=.*/IS_CREATION_ENABLED=${IS_CREATION_ENABLED}/g" /config/config.txt - [[ "${IS_DASHBOARD_ENABLED}" ]] && sed -i "s/IS_DASHBOARD_ENABLED=.*/IS_DASHBOARD_ENABLED=${IS_DASHBOARD_ENABLED}/g" /config/config.txt - [[ "${IS_REGISTRATION_ENABLED}" ]] && sed -i "s/IS_REGISTRATION_ENABLED=.*/IS_REGISTRATION_ENABLED=${IS_REGISTRATION_ENABLED}/g" /config/config.txt - [[ "${CONNECT_WITH_FRANZ}" ]] && sed -i "s/CONNECT_WITH_FRANZ=.*/CONNECT_WITH_FRANZ=${CONNECT_WITH_FRANZ}/g" /config/config.txt - [[ "${DB_CONNECTION}" ]] && sed -i "s/DB_CONNECTION=.*/DB_CONNECTION=${DB_CONNECTION}/g" /config/config.txt - [[ "${DB_HOST}" ]] && sed -i "s/DB_HOST=.*/DB_HOST=${DB_HOST}/g" /config/config.txt - [[ "${DB_PORT}" ]] && sed -i "s/DB_PORT=.*/DB_PORT=${DB_PORT}/g" /config/config.txt - [[ "${DB_DATABASE}" ]] && sed -i "s/DB_DATABASE=.*/DB_DATABASE=${DB_DATABASE}/g" /config/config.txt - [[ "${DB_USER}" ]] && sed -i "s/DB_USER=.*/DB_USER=${DB_USER}/g" /config/config.txt - [[ "${DB_PASSWORD}" ]] && sed -i "s/DB_PASSWORD=.*/DB_PASSWORD=${DB_PASSWORD}/g" /config/config.txt - [[ "${DB_SSL}" ]] && sed -i "s/DB_SSL=.*/DB_SSL=${DB_SSL}/g" /config/config.txt - [[ "${MAIL_CONNECTION}" ]] && sed -i "s/MAIL_CONNECTION=.*/MAIL_CONNECTION=${MAIL_CONNECTION}/g" /config/config.txt - [[ "${SMTP_HOST}" ]] && sed -i "s/SMTP_HOST=.*/SMTP_HOST=${SMTP_HOST}/g" /config/config.txt - [[ "${SMTP_PORT}" ]] && sed -i "s/SMTP_PORT=.*/SMTP_PORT=${SMTP_PORT}/g" /config/config.txt - [[ "${MAIL_SSL}" ]] && sed -i "s/MAIL_SSL=.*/MAIL_SSL=${MAIL_SSL}/g" /config/config.txt - [[ "${MAIL_USERNAME}" ]] && sed -i "s/MAIL_USERNAME=.*/MAIL_USERNAME=${MAIL_USERNAME}/g" /config/config.txt - [[ "${MAIL_PASSWORD}" ]] && sed -i "s/MAIL_PASSWORD=.*/MAIL_PASSWORD=${MAIL_PASSWORD}/g" /config/config.txt - [[ "${MMAIL_SENDER}" ]] && sed -i "s/MAIL_SENDER=.*/MAIL_SENDER=${MAIL_SENDER}/g" /config/config.txt - rm /config/.env - cp /config/config.txt /config/.env -elif [ ! -f /config/config.txt ]; then - echo " " - echo "**** Generating .env file ****" - cp /defaults/.env.example /config/.env - [[ "${NODE_ENV}" ]] && sed -i "s/NODE_ENV=.*/NODE_ENV=${NODE_ENV}/g" /config/.env - [[ "${EXTERNAL_DOMAIN}" ]] && sed -i "s/EXTERNAL_DOMAIN=.*/EXTERNAL_DOMAIN=${EXTERNAL_DOMAIN}/g" /config/.env - [[ "${IS_CREATION_ENABLED}" ]] && sed -i "s/IS_CREATION_ENABLED=.*/IS_CREATION_ENABLED=${IS_CREATION_ENABLED}/g" /config/.env - [[ "${IS_DASHBOARD_ENABLED}" ]] && sed -i "s/IS_DASHBOARD_ENABLED=.*/IS_DASHBOARD_ENABLED=${IS_DASHBOARD_ENABLED}/g" /config/.env - [[ "${IS_REGISTRATION_ENABLED}" ]] && sed -i "s/IS_REGISTRATION_ENABLED=.*/IS_REGISTRATION_ENABLED=${IS_REGISTRATION_ENABLED}/g" /config/.env - [[ "${CONNECT_WITH_FRANZ}" ]] && sed -i "s/CONNECT_WITH_FRANZ=.*/CONNECT_WITH_FRANZ=${CONNECT_WITH_FRANZ}/g" /config/.env - [[ "${DB_CONNECTION}" ]] && sed -i "s/DB_CONNECTION=.*/DB_CONNECTION=${DB_CONNECTION}/g" /config/.env - [[ "${DB_HOST}" ]] && sed -i "s/DB_HOST=.*/DB_HOST=${DB_HOST}/g" /config/.env - [[ "${DB_PORT}" ]] && sed -i "s/DB_PORT=.*/DB_PORT=${DB_PORT}/g" /config/.env - [[ "${DB_DATABASE}" ]] && sed -i "s/DB_DATABASE=.*/DB_DATABASE=${DB_DATABASE}/g" /config/.env - [[ "${DB_USER}" ]] && sed -i "s/DB_USER=.*/DB_USER=${DB_USER}/g" /config/.env - [[ "${DB_PASSWORD}" ]] && sed -i "s/DB_PASSWORD=.*/DB_PASSWORD=${DB_PASSWORD}/g" /config/.env - [[ "${DB_SSL}" ]] && sed -i "s/DB_SSL=.*/DB_SSL=${DB_SSL}/g" /config/.env - [[ "${MAIL_CONNECTION}" ]] && sed -i "s/MAIL_CONNECTION=.*/MAIL_CONNECTION=${MAIL_CONNECTION}/g" /config/.env - [[ "${SMTP_HOST}" ]] && sed -i "s/SMTP_HOST=.*/SMTP_HOST=${SMTP_HOST}/g" /config/.env - [[ "${SMTP_PORT}" ]] && sed -i "s/SMTP_PORT=.*/SMTP_PORT=${SMTP_PORT}/g" /config/.env - [[ "${MAIL_SSL}" ]] && sed -i "s/MAIL_SSL=.*/MAIL_SSL=${MAIL_SSL}/g" /config/.env - [[ "${MAIL_USERNAME}" ]] && sed -i "s/MAIL_USERNAME=.*/MAIL_USERNAME=${MAIL_USERNAME}/g" /config/.env - [[ "${MAIL_PASSWORD}" ]] && sed -i "s/MAIL_PASSWORD=.*/MAIL_PASSWORD=${MAIL_PASSWORD}/g" /config/.env - [[ "${MMAIL_SENDER}" ]] && sed -i "s/MAIL_SENDER=.*/MAIL_SENDER=${MAIL_SENDER}/g" /config/.env - cp /config/.env /config/config.txt -fi - -# update .env -if [ -f /app/.env ]; then - rm /app/.env - ln -s /config/.env /app/.env -elif [ ! -f /app/.env ]; then - ln -s /config/.env /app/.env -fi - -# install adonisjs cli -echo " " -echo "**** Installing AdonisJS and deps ****" -cd /app -echo " " -npm config set unsafe-perm true -npm i -g @adonisjs/cli - -# install adonisjs dependencies -npm install - -# make custom recipe dir -if [ ! -f /app/recipes/dev ]; then -mkdir -p /app/recipes/dev -fi - -# setting the database helper -if [ "${DB_CONNECTION}" = "sqlite" ]; then - echo " " - echo "**** DB helper loaded ****" - else npm i ${DB_CONNECTION} - echo " " - echo "**** DB Helper loaded ****" -fi - -# check for the database endpoint for 30 seconds -echo " " -echo "**** Checking DB endpoint ****" -source .env -END=$((SECONDS+30)) -while [ ${SECONDS} -lt ${END} ] && [ "${DB_HOST} ${DB_PORT}" ]; - do - /usr/bin/nc -z ${DB_HOST} ${DB_PORT} && \ - if [ ! -z "$(/usr/bin/nc -w1 ${DB_HOST} ${DB_PORT})" ]; - then - [ ! -z "${RUN}" ] && break - RUN="RAN" - # we sleep here again due to first run init on DB containers - [ ! -f /dbwait.lock ] && sleep 5 - else - sleep 1 - fi - sleep 1 -done - -# source the .env file -source .env - -# database migration -echo " " -echo "**** Run DB migration ****" -adonis migration:run --force - -# Create APP key if needed -if [ ! -f "/config/FERDI_APP_KEY.txt" ]; - then - echo " " - echo "**** Generating Ferdi-server app key for first run ****" - adonis key:generate - source .env - echo $APP_KEY > /config/FERDI_APP_KEY.txt - echo "**** App Key set to $APP_KEY you can modify FERDI_APP_KEY.txt to update your key ****" - sed -i "s/APP_KEY=/APP_KEY=$APP_KEY/g" /config/config.txt -elif [ -f "/config/FERDI_APP_KEY.txt" ]; - then - echo " " - echo "**** App Key found ****" - APP_KEY=$(cat /config/FERDI_APP_KEY.txt) - sed -i "s/APP_KEY=.*/APP_KEY=$APP_KEY/g" /config/config.txt - echo "**** App Key set to $APP_KEY you can modify FERDI_APP_KEY.txt to update your key ****" -fi - -# set permissions -chown -R abc:abc \ - /config \ - /app - -# set lockfile to avoid DB waits for this specific container -touch /dbwait.lock diff --git a/docker/root/etc/services.d/ferdi-server/run b/docker/root/etc/services.d/ferdi-server/run deleted file mode 100755 index cf1568c..0000000 --- a/docker/root/etc/services.d/ferdi-server/run +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/with-contenv bash - -cd /app - -setcap 'cap_net_bind_service=+ep' `which node` - -# start server -echo " " -echo "**** Starting Ferdi-server ****" -exec s6-setuidgid abc adonis serve --dev \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 0a3ce5a9e37dd917cfabdf97fdc18a41d88c65eb Mon Sep 17 00:00:00 2001 From: Michal Kostewicz Date: Tue, 9 Feb 2021 21:28:23 +0100 Subject: Fix all issues found on CR -> especially update README.md, remove creation of new config.txt, update ignore files. --- .dockerignore | 7 ++++--- .env.example | 2 +- .gitignore | 3 +-- README.md | 4 ++-- docker/.gitignore | 4 ---- docker/README.md | 16 +++++----------- docker/entrypoint.sh | 16 +++++----------- 7 files changed, 18 insertions(+), 34 deletions(-) (limited to '.dockerignore') diff --git a/.dockerignore b/.dockerignore index 7dad3a9..01c565b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,10 +7,11 @@ .gitattributes .cache -# ignore all markdown files (md) beside all README*.md other than README-secret.md +# ignore all markdown files *.md -!README*.md -README-secret.md + +# Ignore database files +*.sqlite # ignore other directories docker diff --git a/.env.example b/.env.example index b11a2cc..a11ce1f 100644 --- a/.env.example +++ b/.env.example @@ -10,7 +10,7 @@ CACHE_VIEWS=false APP_KEY= -DATA_DIR=database +DATA_DIR= DB_CONNECTION=sqlite DB_HOST=127.0.0.1 diff --git a/.gitignore b/.gitignore index 0f1f969..267390d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,8 +8,7 @@ tmp .env # The development sqlite file -database/development.sqlite -database/adonis.sqlite +*.sqlite # Uploaded recipes recipes/ diff --git a/README.md b/README.md index 60de4fc..2e0d9f9 100644 --- a/README.md +++ b/README.md @@ -78,11 +78,11 @@ After setting up the docker container we recommend you to set up an NGINX revers getferdi/ferdi-server ``` - Alternatively, you can also use docker-compose v2 schemas. An example can be found in [./docker/docker-compose.yml](https://github.com/getferdi/server/tree/master/docker/docker-compose.yml) file. + Alternatively, you can also use docker-compose v2 schema. An example can be found [in the docker folder](./docker/docker-compose.yml). 3. Optionally, you can now [set up Nginx as a reverse proxy](https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04#set-up-nginx-as-a-reverse-proxy-server). -For more information on configuring the Docker image, please read [./docker/README.md](https://github.com/getferdi/server/tree/master/docker/README.md). +For more information on configuring the Docker image, please read [the ferdi docker documentation](./docker/README.md). ### Manual setup 1. Clone this repository diff --git a/docker/.gitignore b/docker/.gitignore index b726524..552cd4a 100644 --- a/docker/.gitignore +++ b/docker/.gitignore @@ -4,10 +4,6 @@ node_modules # Adonis directory for storing tmp files tmp -# The development sqlite file -database/development.sqlite -database/adonis.sqlite - # Uploaded recipes recipes/ diff --git a/docker/README.md b/docker/README.md index 8518e15..1cea8ae 100644 --- a/docker/README.md +++ b/docker/README.md @@ -76,9 +76,11 @@ The server will be launched at [http://localhost:3333/](http://localhost:3333/) ## Configuration -Container images are configured using parameters passed at runtime (such as those above). These parameters are separated by a colon and indicate `:` respectively. For example, `-p 3333:80` would expose port `80` from inside the container to be accessible from the host's IP on port `3333` outside the container. -After the first run, Ferdi-server's default configuration is saved inside the `config.txt` file inside your persistent data directory (`/config` in the container). -If any environmental parameter is not passed to the container, its value will be taken from the `config.txt` file. You can also edit the `config.txt` file, but it is advisable to send the environment parameters to the container. +Container images are configured using parameters passed at runtime (such as those above). + +**Warning ,using `config.txt` will be deprecated in the future releases.** + +If any of environmental parameters is not passed to the container, its value will be taken from the `/config/config.txt` file. **The previous functionality of saving container parameters in this file is now removed.** | Parameter | Function | | :----: | --- | @@ -213,13 +215,5 @@ docker build \ -t getferdi/ferdi-server:latest . ``` -## Versions - -* **05.02.21:** - Repository moved to ferdi-server repository -* **19.01.21:** - Updated Mail SSL and DB SLL settings -* **20.09.20:** - Updated SMTP Mailer settings for password reset. -* **21.06.20:** - Rebase to Alpine 3.11 and added Mailer settings. -* **25.09.19:** - Initial Release. - ## License Ferdi-server-docker and ferdi-server are licensed under the MIT License. diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 0bbcb9d..eac3fc8 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -14,17 +14,11 @@ Support our Open Collective at: https://opencollective.com/getferdi/ EOL -# if config.txt doesn't exist then create one with default values -if [ ! -f /config/config.txt ]; then - cp /app/.env.example /config/config.txt -fi - -# use config.txt default values as .env file -if [ -f /app/.env ]; then - rm /app/.env - ln -s /config/config.txt /app/.env -elif [ ! -f /app/.env ]; then - ln -s /config/config.txt /app/.env +# use config.txt or .env.example parameter values as default if they are not passed to container +if [ -f /config/config.txt ]; then + cp /config/config.txt /app/.env +else + cp /app/.env.example /app/.env fi # Create APP key if needed -- cgit v1.2.3-54-g00ecf From c039b3ebde1e0f73ab1f465fa0c752bbbac990be Mon Sep 17 00:00:00 2001 From: thursday Date: Thu, 8 Jul 2021 16:33:26 -0400 Subject: Update .dockerignore --- .dockerignore | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to '.dockerignore') diff --git a/.dockerignore b/.dockerignore index 01c565b..93c1caf 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,10 +1,7 @@ .DS_Store # ignore .git and .cache folders -.git -.gitignore -.github -.gitattributes +.git* .cache # ignore all markdown files -- cgit v1.2.3-54-g00ecf From d7eea009ef5137fa566b13bf62ee5a84ad3621ec Mon Sep 17 00:00:00 2001 From: thursday Date: Tue, 13 Jul 2021 04:13:00 -0400 Subject: Update .dockerignore Still trying to fix the .env problem --- .dockerignore | 1 + 1 file changed, 1 insertion(+) (limited to '.dockerignore') diff --git a/.dockerignore b/.dockerignore index 93c1caf..110334e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -13,6 +13,7 @@ # ignore other directories docker !docker/entrypoint.sh +!docker/.env node_modules -- cgit v1.2.3-54-g00ecf From 7e0f6b5e3a845af0e4d88e8164ce38253a0bd5c6 Mon Sep 17 00:00:00 2001 From: thursday Date: Sun, 18 Jul 2021 16:34:27 -0400 Subject: Update .dockerignore Trying to build without node_modules in the docker ignore to see if that will avoid the current problems running the container without installing the server at runtime. --- .dockerignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.dockerignore') diff --git a/.dockerignore b/.dockerignore index 110334e..99ed609 100644 --- a/.dockerignore +++ b/.dockerignore @@ -14,7 +14,7 @@ docker !docker/entrypoint.sh !docker/.env -node_modules +#node_modules -- cgit v1.2.3-54-g00ecf From 3898a5352715386fadd19d832937819dd12c2e0f Mon Sep 17 00:00:00 2001 From: thursday Date: Mon, 19 Jul 2021 03:47:23 -0400 Subject: Update .dockerignore --- .dockerignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.dockerignore') diff --git a/.dockerignore b/.dockerignore index 99ed609..110334e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -14,7 +14,7 @@ docker !docker/entrypoint.sh !docker/.env -#node_modules +node_modules -- cgit v1.2.3-54-g00ecf