diff --git a/Dockerfile-Develop b/Dockerfile-Develop new file mode 100644 index 00000000..23a536c4 --- /dev/null +++ b/Dockerfile-Develop @@ -0,0 +1,14 @@ +# Final Develop Image +FROM node:10-alpine + +WORKDIR /app/ + +# Install system dependencies +RUN set -ex; \ + apk add --update --no-cache \ + make gcc g++ git python pwgen netcat-openbsd bash imagemagick + +EXPOSE 3000 3003 3004 + +# Keep container running, so you can access it +CMD tail -f /dev/null \ No newline at end of file diff --git a/README.md b/README.md index c15445e6..7c949544 100644 --- a/README.md +++ b/README.md @@ -199,6 +199,32 @@ These are the steps to start Mailtrain via docker-compose: The instructions above use an automatically built Docker image on DockerHub (https://hub.docker.com/r/mailtrain/mailtrain). If you want to build the Docker image yourself (e.g. when doing development), use the `docker-compose-local.yml` located in the project's root directory. + +### Deployment with Docker and Docker compose (for development) +This setup starts a stack like above, but is tweaked to be used for local development using docker containers. + +1. Clone this repository + +2. Bring up the development stack + ``` + docker-compose -f docker-compose-develop.yml up -d + ``` +3. Connect to a shell inside the container + ``` + docker-compose exec mailtrain bash + ``` +4. Run these commands once to install all the node modules and build the client webapp + ``` + cd /app + bash setup/reinstall-modules.sh + cd /app/client && npm run build && cd /app + +5. Start the server for the first time with this command, to generate the `server/config/production.yaml` + ``` + bash docker-entrypoint.sh + ``` + + ### Docker Environment Variables When using Docker, you can override the default Mailtrain settings via the following environment variables. These variables have to be defined in the docker-compose config file. You can give them a value directly in the `docker-compose.yml` config file. diff --git a/docker-compose-develop.yml b/docker-compose-develop.yml new file mode 100644 index 00000000..dcd0dcfd --- /dev/null +++ b/docker-compose-develop.yml @@ -0,0 +1,38 @@ +version: '3' + +services: + mysql: + image: mariadb:10.4 + environment: + - MYSQL_ROOT_PASSWORD=mailtrain + - MYSQL_DATABASE=mailtrain + - MYSQL_USER=mailtrain + - MYSQL_PASSWORD=mailtrain + volumes: + - mysql-data:/var/lib/mysql + + redis: + image: redis:5 + volumes: + - redis-data:/data + + mongo: + image: mongo:4-xenial + volumes: + - mongo-data:/data/db + + mailtrain: + build: + context: . + dockerfile: Dockerfile-Develop + ports: + - "3000:3000" + - "3003:3003" + - "3004:3004" + volumes: + - ./:/app + +volumes: + mysql-data: + redis-data: + mongo-data: \ No newline at end of file