Skip to content

ronnycoding/adonisjsfancydev

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

This image extends node:latest oficial image and adds:

How to use this image

The basic pattern for starting an Adonisjs instance is:

$ docker run --name some-adonisjs -d ronnf89/adonisjsfancydev

If you'd like to be able to access the instance from the host without the container's IP, standard port mappings can be used:

$ docker run --name some-adonisjs -p 8080:80 -d ronnf89/adonisjsfancydev

Then, access it via http://localhost:8080 or http://host-ip:8080 in a browser.

There are multiple database types supported by this image, most easily used via standard container linking. In the default configuration, SQLite can be used to avoid a second container and write to flat-files. More detailed instructions for different (more production-ready) database types follow.

When first accessing the webserver provided by this image, it will go through a brief setup process. The details provided below are specifically for the "Set up database" step of that configuration process.

Adonisjs CLI

By default, this image includes composer. Run Adonis CLI into a running container as the following command:

$ docker exec CONTAINER_ID adonis --help

MySQL

$ docker run --name some-adonisjs --link some-mysql:mysql -d ronnf89/adonisjsfancydev
  • Database type: MySQL, MariaDB, or equivalent
  • Database name/username/password:
    (MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE; see environment variables in the description for mysql)
  • ADVANCED OPTIONS; Database host: mysql (for using the /etc/hosts entry added by --link to access the linked container's MySQL instance)

PostgreSQL

$ docker run --name some-adonisjs --link some-postgres:postgres -d ronnf89/adonisjsfancydev
  • Database type: PostgreSQL
  • Database name/username/password:
    (POSTGRES_USER, POSTGRES_PASSWORD; see environment variables in the description for postgres)
  • ADVANCED OPTIONS; Database host: postgres (for using the /etc/hosts entry added by --link to access the linked container's PostgreSQL instance)

Volumes

By default, this image does not include any volumes.

This can be bind-mounted into a new container:

$ docker run --name some-adonisjs --link some-postgres:postgres -d \
    -v /path/on/host/app:/var/www/app \
    -v /path/on/host/config:/var/www/config \
    -v /path/on/host/database:/var/www/database \
    -v /path/on/host/public:/var/www/public \
    -v /path/on/host/resources:/var/www/resources \
    -v /path/on/host/start:/var/www/start \
    ronnf89/adonisjsfancydev
  • add .env file at the root of your project with the following lines
DOMAIN=adonisjs
HOST=0.0.0.0
PORT=80
NODE_ENV=development
APP_URL=http://${HOST}:${PORT}
CACHE_VIEWS=false
APP_KEY=[YOUR APP KEY GENERATED BY COMMAND "adonis key:generate"]
DB_CONNECTION=pg
DB_HOST=postgres
DB_PORT=5432
DB_USER=adonis
DB_PASSWORD=adonis
DB_DATABASE=adonis
SESSION_DRIVER=cookie
HASH_DRIVER=bcrypt
  • add docker-compose.yml file at the root of your project with the following lines.
version: '3.1'

networks:
  adonisjs:
    external: false

services:
  traefik:
    container_name: ${DOMAIN}-traefik
    image: traefik
    command: --web --docker --docker.domain=${DOMAIN}.localhost --logLevel=DEBUG
    ports:
      - "82:80"
      - "8082:8080"
      - "8028:8025"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /dev/null:/traefik.toml
    networks:
      - adonisjs

  app:
    container_name: ${DOMAIN}-adonisjs
    image: ronnf89/adonisjsfancydev
    volumes:
      - .:/var/www
      - /var/www/node_modules
    labels:
      - "traefik.backend=app-${DOMAIN}"
      - "traefik.frontend.rule=Host:app.${DOMAIN}.localhost"
      - "traefik.port=80"
    restart: always
    depends_on:
      - postgres
    networks:
      - adonisjs

  postgres:
    container_name: ${DOMAIN}-postgres
    image: postgres:10
    environment:
      - POSTGRES_PGDATA=/var/lib/postgresql/data/pgdata
      - POSTGRES_USER=${DB_USER}
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DB=${DB_DATABASE}
    restart: always
    volumes:
      - ./db-data:/var/lib/postgresql/data
    networks:
      - adonisjs
    labels:
      - "traefik.enable=false"

  adminer:
    container_name: ${DOMAIN}-adminer
    image: adminer
    restart: always
    links:
      - postgres
    labels:
      - "traefik.backend=adminer-${DOMAIN}"
      - "traefik.frontend.rule=Host:adminer.${DOMAIN}.localhost"
      - "traefik.port=8080"
    networks:
      - adonisjs
    
  mailhog:
    container_name: ${DOMAIN}-mailhog
    image: mailhog/mailhog
    labels:
      - "traefik.backend=mail-${DOMAIN}"
      - "traefik.frontend.rule=Host:mail.${DOMAIN}.localhost"
      - "traefik.port=8025"
    networks:
      - adonisjs
  
volumes:
  db-data:
    driver: local
  • Run command at your project root:
$ docker-compose up -d

Now you can access to your differents container services.

Thanks for read me, please share me to your adonisjs community.

License

MIT

Free Software, Hell Yeah!

Releases

No releases published

Packages

No packages published