-
-
Notifications
You must be signed in to change notification settings - Fork 52
Installing (Docker)
Movin' In can run in a Docker container on Linux and Docker Desktop for Windows or Mac.
This section describes how to build Movin' In Docker image and run it in a Docker container.
- Clone Movin' In repo:
git clone https://github.com/aelassas/movinin.git
- Create
./api/.env.docker
file with the following content:
NODE_ENV=production
MI_PORT=4004
MI_HTTPS=false
MI_PRIVATE_KEY=/etc/ssl/movinin.key
MI_CERTIFICATE=/etc/ssl/movinin.crt
MI_DB_URI=mongodb://admin:PASSWORD@mongo:27017/movinin?authSource=admin&appName=movinin
MI_DB_SSL=false
MI_DB_SSL_CERT=/etc/ssl/movinin.crt
MI_DB_SSL_CA=/etc/ssl/movinin.ca.pem
MI_DB_DEBUG=false
MI_COOKIE_SECRET=COOKIE_SECRET
MI_AUTH_COOKIE_DOMAIN=localhost
MI_JWT_SECRET=JWT_SECRET
MI_JWT_EXPIRE_AT=86400
MI_TOKEN_EXPIRE_AT=86400
MI_SMTP_HOST=smtp.sendgrid.net
MI_SMTP_PORT=587
MI_SMTP_USER=apikey
MI_SMTP_PASS=PASSWORD
MI_SMTP_FROM=admin@movinin.ma
MI_CDN_USERS=/var/www/cdn/movinin/users
MI_CDN_TEMP_USERS=/var/www/cdn/movinin/temp/users
MI_CDN_PROPERTIES=/var/www/cdn/movinin/properties
MI_CDN_TEMP_PROPERTIES=/var/www/cdn/movinin/temp/properties
MI_CDN_LOCATIONS=/var/www/cdn/movinin/locations
MI_CDN_TEMP_LOCATIONS=/var/www/cdn/movinin/temp/locations
MI_DEFAULT_LANGUAGE=en
MI_BACKEND_HOST=http://localhost:3003/
MI_FRONTEND_HOST=http://localhost/
MI_MINIMUM_AGE=21
MI_EXPO_ACCESS_TOKEN=EXPO_ACCESS_TOKEN
MI_STRIPE_SECRET_KEY=STRIPE_SECRET_KEY
MI_ADMIN_EMAIL=admin@movinin.io
MI_RECAPTCHA_SECRET=RECAPTCHA_SECRET
MI_WEBSITE_NAME="Movin' In"
Set the following options:
MI_DB_URI=mongodb://admin:PASSWORD@mongo:27017/movinin?authSource=admin&appName=movinin
MI_COOKIE_SECRET=COOKIE_SECRET
MI_AUTH_COOKIE_DOMAIN=localhost
MI_JWT_SECRET=JWT_SECRET
MI_SMTP_HOST=smtp.sendgrid.net
MI_SMTP_PORT=587
MI_SMTP_USER=apikey
MI_SMTP_PASS=PASSWORD
MI_SMTP_FROM=admin@movinin.io
MI_BACKEND_HOST=http://localhost:3003/
MI_FRONTEND_HOST=http://localhost/
If you want to use MongoDB Atlas, put you MongoDB Atlas URI in MI_DB_URI
otherwise replace PASSWORD
in MI_DB_URI
with your MongoDB password. Replace JWT_SECRET
with a secret token. Finally, set the SMTP options. SMTP options are necessary for sign up. You can use sendgrid or any other transactional email provider.
If you choose sendgrid, create an account on sendgrid.com, login and go to the dashboard. On the left panel, click on Email API, then on Integration Guide. Then, choose SMTP Relay and follow the steps. You will be prompted to create an API Key. Once you create the API Key and verify the smtp relay, copy the API key in MI_SMTP_PASS
in ./api/.env. Sendgrid's free plan allows to send up to 100 emails/day. If you need to send more than 100 emails/day, switch to a paid plan or choose another transactional email provider.
COOKIE_SECRET
and JWT_SECRET
should at least be 32 characters long, but the longer the better. You can use an online password generator and set the password length to 32 or longer.
The following settings are very important and if they are not set properly, authentication won't work:
MI_AUTH_COOKIE_DOMAIN=localhost
MI_BACKEND_HOST=http://localhost:3001/
MI_FRONTEND_HOST=http://localhost/
Replace localhost
with an IP or FQDN. That is if you access the backend from http://<FQDN>:3001/. MI_BACKEND_HOST
should be http://<FQDN>:3001/. The same goes for MI_FRONTEND_HOST
. And MI_AUTH_COOKIE_DOMAIN
should be FQDN.
Leave localhost
if you want to test locally.
If you want to enable push notifications in the mobile app, follow these instructions and set the following option:
MI_EXPO_ACCESS_TOKEN=EXPO_ACCESS_TOKEN
If you want to enable stripe payment gateway, sign up for a stripe account, fill the forms and save the publishable key and the secret key from stripe dashboard. Then, set the secret key in the following option in api/.env:
MI_STRIPE_SECRET_KEY=STRIPE_SECRET_KEY
Don't expose stripe secret key on a website or embed it in a mobile application. It must be secret and stored securely in the server-side.
In stripe, all accounts have a total of four API keys by default-two for test mode and two for live mode:
- Test mode secret key: Use this key to authenticate requests on your server when in test mode. By default, you can use this key to perform any API request without restriction.
- Test mode publishable key: Use this key for testing purposes in your web or mobile app’s client-side code.
- Live mode secret key: Use this key to authenticate requests on your server when in live mode. By default, you can use this key to perform any API request without restriction.
- Live mode publishable key: Use this key, when you’re ready to launch your app, in your web or mobile app’s client-side code.
Use only your test API keys for testing. This ensures that you don't accidentally modify your live customers or charges.
- Create
./backend/.env.docker
file with the following content:
VITE_NODE_ENV=production
VITE_MI_API_HOST=http://localhost:4004
VITE_MI_DEFAULT_LANGUAGE=en
VITE_MI_PAGE_SIZE=30
VITE_MI_PROPERTIES_PAGE_SIZE=15
VITE_MI_BOOKINGS_PAGE_SIZE=20
VITE_MI_BOOKINGS_MOBILE_PAGE_SIZE=10
VITE_MI_CDN_USERS=http://localhost/cdn/movinin/users
VITE_MI_CDN_TEMP_USERS=http://localhost/cdn/movinin/temp/users
VITE_MI_CDN_PROPERTIES=http://localhost/cdn/movinin/properties
VITE_MI_CDN_TEMP_PROPERTIES=http://localhost/cdn/movinin/temp/properties
VITE_MI_CDN_LOCATIONS=http://localhost/cdn/movinin/locations
VITE_MI_CDN_TEMP_LOCATIONS=http://localhost/cdn/movinin/temp/locations
VITE_MI_AGENCY_IMAGE_WIDTH=60
VITE_MI_AGENCY_IMAGE_HEIGHT=30
VITE_MI_PROPERTY_IMAGE_WIDTH=300
VITE_MI_PROPERTY_IMAGE_HEIGHT=200
VITE_MI_APP_TYPE=backend
VITE_MI_MINIMUM_AGE=21
VITE_MI_PAGINATION_MODE=classic
VITE_MI_CURRENCY=\$
VITE_MI_WEBSITE_NAME="Movin' In"
Set the following options:
VITE_MI_API_HOST=http://localhost:4004
VITE_MI_CDN_USERS=http://localhost/cdn/movinin/users
VITE_MI_CDN_TEMP_USERS=http://localhost/cdn/movinin/temp/users
VITE_MI_CDN_PROPERTIES=http://localhost/cdn/movinin/properties
VITE_MI_CDN_TEMP_PROPERTIES=http://localhost/cdn/movinin/temp/properties
VITE_MI_CDN_LOCATIONS=http://localhost/cdn/movinin/locations
VITE_MI_CDN_TEMP_LOCATIONS=http://localhost/cdn/movinin/temp/locations
Leave localhost
if you want to test locally or Replace it with an IP, hostname or FQDN.
If you want to change pagination mode, change VITE_MI_PAGINATION_MODE
option. You can choose between classic
or infinite_scroll
. This option defaults to classic
. If you choose classic
, you will get a classic pagination with next and previous buttons on desktop and infinite scroll on mobile. If you choose infinite_scroll
, you will get infinite scroll on desktop and mobile.
- Create
./frontend/.env.docker
file with the following content:
VITE_NODE_ENV=production
VITE_MI_API_HOST=http://localhost:4004
VITE_MI_RECAPTCHA_ENABLED=false
VITE_MI_DEFAULT_LANGUAGE=en
VITE_MI_PAGE_SIZE=30
VITE_MI_PROPERTIES_PAGE_SIZE=15
VITE_MI_BOOKINGS_PAGE_SIZE=20
VITE_MI_BOOKINGS_MOBILE_PAGE_SIZE=10
VITE_MI_CDN_USERS=http://localhost/cdn/movinin/users
VITE_MI_CDN_PROPERTIES=http://localhost/cdn/movinin/properties
VITE_MI_CDN_LOCATIONS=http://localhost/cdn/movinin/locations
VITE_MI_AGENCY_IMAGE_WIDTH=60
VITE_MI_AGENCY_IMAGE_HEIGHT=30
VITE_MI_PROPERTY_IMAGE_WIDTH=300
VITE_MI_PROPERTY_IMAGE_HEIGHT=200
VITE_MI_APP_TYPE=frontend
VITE_MI_MINIMUM_AGE=21
VITE_MI_PAGINATION_MODE=classic
VITE_MI_STRIPE_PUBLISHABLE_KEY=STRIPE_PUBLISHABLE_KEY
VITE_MI_BASE_CURRENCY=USD
VITE_MI_FB_APP_ID=XXXXXXXXXX
VITE_MI_APPLE_ID=XXXXXXXXXX
VITE_MI_GG_APP_ID=XXXXXXXXXX
VITE_MI_MIN_LOCATIONS=4
VITE_MI_CONTACT_EMAIL=info@movinin.io
VITE_MI_WEBSITE_NAME="Movin' In"
Set the following options:
VITE_MI_API_HOST=http://localhost:4004
VITE_MI_CDN_USERS=http://localhost/cdn/movinin/users
VITE_MI_CDN_PROPERTIES=http://localhost/cdn/movinin/properties
VITE_MI_CDN_LOCATIONS=http://localhost/cdn/movinin/locations
VITE_MI_STRIPE_PUBLISHABLE_KEY=STRIPE_PUBLISHABLE_KEY
VITE_MI_BASE_CURRENCY=USD
VITE_MI_FB_APP_ID=XXXXXXXXXX
VITE_MI_APPLE_ID=XXXXXXXXXX
VITE_MI_GG_APP_ID=XXXXXXXXXX
VITE_MI_CONTACT_EMAIL=info@movinin.io
Leave localhost
if you want to test locally or Replace it with an IP, hostname or FQDN.
For Google Auth, you need to create OAuth 2.0 client ID and add your domains here and set VITE_MI_GG_APP_ID
. Do the samething for VITE_MI_APPLE_ID
here and VITE_MI_FB_APP_ID
here.
If you want to enable stripe payment gateway, set stripe publishable key in VITE_BC_STRIPE_PUBLISHABLE_KEY
. You can retrieve it from stripe dashboard.
VITE_MI_BASE_CURRENCY
is the three-letter ISO 4217 alphabetic currency code, e.g. "USD" or "EUR". Required for Stripe payments. Must be a supported currency: https://docs.stripe.com/currencies
If you want to change pagination mode, change VITE_MI_PAGINATION_MODE
option.
reCAPTCHA is by default disabled on the frontend. If you want to enable it, you have to set VITE_MI_RECAPTCHA_ENABLED
to true
and VITE_MI_RECAPTCHA_SITE_KEY
to Google reCAPTCHA site key.
- Open
./docker-compose.yml
and set MongoDB password:
version: "3.8"
services:
api:
build:
context: .
dockerfile: ./api/Dockerfile
env_file: ./api/.env.docker
restart: always
ports:
- 4004:4004
depends_on:
- mongo
volumes:
- cdn:/var/www/cdn/movinin
mongo:
image: mongo:latest
command: mongod --quiet --logpath /dev/null
restart: always
environment:
# Provide your credentials here
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: PASSWORD
ports:
- 27017:27017
backend:
build:
context: .
dockerfile: ./backend/Dockerfile
depends_on:
- api
ports:
- 3003:3003
frontend:
build:
context: .
dockerfile: ./frontend/Dockerfile
depends_on:
- api
ports:
- 80:80
volumes:
- cdn:/var/www/cdn/movinin
volumes:
cdn:
If you want to use MongoDB Atlas, remove mongo
container. Otherwise, replace PASSWORD
with the password that you have set in MI_DB_URI
in ./api/.env.docker
.
- Build and run docker image:
docker compose up
To run the compose in background, add the -d
option with the command:
docker compose up -d
If you want to rebuild, use the following command:
docker compose up --build --force-recreate --no-deps api backend frontend
If you want to rebuild without cache, use the following commands:
docker compose build --no-cache api backend frontend
docker compose up
If you want to check the logs of the containers for troubleshooting, use the following command:
docker compose logs
That's it! Movin' In backend is accessible from http://<hostname>:3003 and Movin' In frontend is accessible from http://<hostname>.
If you run Movin' In for the first time, you'll start from an empty database. So you have to create an admin user from the backend by filling the from http://<hostname>:3003/sign-up. SMTP settings must configured to process sign up. Then, secure the backend by opening backend/src/App.tsx
and commenting the following lines:
const SignUp = lazy(() => import('./pages/SignUp'))
<Route exact path='/sign-up' element={<Signup />} />
You'll need to rebuild and run Docker image:
docker compose build --no-cache
docker compose up
Once you create the admin user, do the following:
- Go to the suppliers page and create one or multiple suppliers
- Go to the locations page and create one or multiple locations
- Go to the properties page and create one or multiple properties
- Go to the frontend, sign up, choose a property and checkout.
Finally, you will see bookings listed in the backend dashboard.
You can use the demo database if you want to.
Below are Docker configuration files:
- API: Dockerfile
- Backend: Dockerfile
- Frontend: Dockerfile
- Movin' In: docker-compose.yml
That's it. You can explore the other pages in the backend and the frontend.
This section will walk you through how to enable SSL in the API, the backend and the frontend in a docker container.
Copy your private key movinin.key
and your certificate movinin.crt
in ./
next to docker-compose.yml
.
movinin.key
will be loaded as /etc/ssl/movinin.key
and movinin.crt
will be loaded as /etc/ssl/movinin.crt
in ./docker-compose.yml
.
For the API, update ./api/.env.docker
as follows to enable SSL:
MI_HTTPS=true
MI_PRIVATE_KEY=/etc/ssl/movinin.key
MI_CERTIFICATE=/etc/ssl/movinin.crt
MI_BACKEND_HOST=http://localhost:3003/
MI_FRONTEND_HOST=http://localhost/
Replace http://localhost
with https://<fqdn>
.
For the backend, update the following options in ./backend/.env.docker
:
VITE_MI_API_HOST=http://localhost:4004
VITE_MI_CDN_USERS=http://localhost/cdn/movinin/users
VITE_MI_CDN_TEMP_USERS=http://localhost/cdn/movinin/temp/users
VITE_MI_CDN_PROPERTIES=http://localhost/cdn/movinin/properties
VITE_MI_CDN_TEMP_PROPERTIES=http://localhost/cdn/movinin/temp/properties
Replace http://localhost
with https://<fqdn>
.
Then, update ./backend/nginx.conf
as follows to enable SSL:
server {
listen 3003 ssl;
root /usr/share/nginx/html;
index index.html;
ssl_certificate_key /etc/ssl/movinin.key;
ssl_certificate /etc/ssl/movinin.crt;
error_page 497 301 =307 https://$host:$server_port$request_uri;
access_log /var/log/nginx/backend.access.log;
error_log /var/log/nginx/backend.error.log;
location / {
# First attempt to serve request as file, then as directory,
# then as index.html, then fall back to displaying a 404.
try_files $uri $uri/ /index.html =404;
}
}
For the frontend, update the following options in ./frontend/.env.docker
:
VITE_MI_API_HOST=http://localhost:4004
VITE_MI_CDN_USERS=http://localhost/cdn/movinin/users
VITE_MI_CDN_PROPERTIES=http://localhost/cdn/movinin/properties
Replace http://localhost
with https://<fqdn>
.
Add the port 443 to ./frontend/Dokerfile
as follows:
# syntax=docker/dockerfile:1
FROM node:lts-alpine as build
WORKDIR /movinin/frontend
COPY ./frontend ./
COPY ./frontend/.env.docker .env
COPY ./packages /movinin/packages
RUN npm install --force
RUN npm run build
FROM nginx:stable-alpine
WORKDIR /usr/share/nginx/html
RUN rm -rf *
COPY --from=build /movinin/frontend/build .
COPY ./frontend/nginx.conf /etc/nginx/conf.d/default.conf
CMD ["nginx", "-g", "daemon off;"]
EXPOSE 80
EXPOSE 443
Then, update ./frontend/nginx.conf
as follows to enable SSL:
server {
listen 80;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
root /usr/share/nginx/html;
index index.html;
ssl_certificate_key /etc/ssl/movinin.key;
ssl_certificate /etc/ssl/movinin.crt;
access_log /var/log/nginx/frontend.access.log;
error_log /var/log/nginx/frontend.error.log;
location / {
# First attempt to serve request as file, then as directory,
# then as index.html, then fall back to displaying a 404.
try_files $uri $uri/ /index.html =404;
}
location /cdn {
alias /var/www/cdn;
}
}
Update ./docker-compose.yml
to load your private key movinin.key
and your certificate movinin.crt
, and add the port 443 to the frontend as follows:
version: "3.8"
services:
api:
build:
context: .
dockerfile: ./api/Dockerfile
env_file: ./api/.env.docker
restart: always
ports:
- 4004:4004
depends_on:
- mongo
volumes:
- cdn:/var/www/cdn/movinin
- ./movinin.key:/etc/ssl/movinin.key
- ./movinin.crt:/etc/ssl/movinin.crt
mongo:
image: mongo:latest
restart: always
environment:
# Provide your credentials here
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: PASSWORD
ports:
- 27017:27017
backend:
build:
context: .
dockerfile: ./backend/Dockerfile
depends_on:
- api
ports:
- 3003:3003
volumes:
- ./movinin.key:/etc/ssl/movinin.key
- ./movinin.crt:/etc/ssl/movinin.crt
frontend:
build:
context: .
dockerfile: ./frontend/Dockerfile
depends_on:
- api
ports:
- 80:80
- 443:443
volumes:
- cdn:/var/www/cdn/movinin
- ./movinin.key:/etc/ssl/movinin.key
- ./movinin.crt:/etc/ssl/movinin.crt
volumes:
cdn:
Rebuild and run Docker image:
docker compose build --no-cache
docker compose up
Copyright © 2025 Akram El Assas. All rights reserved.