Reading time: 2 minutes
Today we’re going to see how we can deploy a container to store notes or links to our interesting websites or projects.
Based on benotes (https://github.com/fr0tt/benotes_docker-compose
)
The first thing we need to do is create this Docker Compose:
version: "3.6" services: benotes_app: container_name: benotes_app image: fr0tt/benotes:2.7.0-beta restart: unless-stopped environment: DB_CONNECTION: ${DB_CONNECTION} #ports: #- ${APP_PORT}:80 volumes: - .env:/var/www/.env #- ./data/storage/app/public/thumbnails:/var/www/storage/app/public/thumbnails #- ./data/storage/backup:/var/www/storage/backup #- ./data/storage/logs:/var/www/storage/logs # or instead one named volume to rule them all: - benotes_storage:/var/www/storage # this is optional (either way): #- ./data/nginx/logs/:/var/lib/nginx/logs/ networks: - docker_network benotes_db: container_name: benotes_db image: postgres:15.2-alpine restart: unless-stopped environment: POSTGRES_DATABASE: ${DB_DATABASE} POSTGRES_USER: ${DB_USERNAME} POSTGRES_PASSWORD: ${DB_PASSWORD} ports: - ${DB_PORT} volumes: - benotes_postgres:/var/lib/postgres/data networks: - docker_network # # If you wish to use MySQL instead remove the lines above, uncomment the following # and change APP_PORT in your .env file to 3306 # # db: # container_name: benotes_db # image: mysql:5.7 # restart: unless-stopped # environment: # MYSQL_DATABASE: ${DB_DATABASE} # MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} # MYSQL_USER: ${DB_USERNAME} # MYSQL_PASSWORD: ${DB_PASSWORD} # ports: # - ${DB_PORT} # volumes: # - benotes_mysql:/var/lib/mysql # networks: # - docker_network volumes: benotes_postgres: driver: "local" # benotes_mysql: # driver: "local" benotes_storage: driver: "local" networks: docker_network: external: true
Once the file is created, we add this .env file in the root directory. Docker Compose reads the .env file directly.
APP_PORT=8099 APP_NAME=Benotes APP_ENV=production APP_DEBUG=false APP_URL=http://localhost:${APP_PORT} APP_TIMEZONE=UTC GENERATE_MISSING_THUMBNAILS=true USE_FILESYSTEM=true DB_CONNECTION=pgsql DB_HOST=benotes_db DB_PORT=5432 DB_DATABASE=db_benotes DB_USERNAME=user_benotes DB_PASSWORD=pass_benotes CACHE_DRIVER=file MAIL_DRIVER=smtp MAIL_HOST= MAIL_PORT=587 MAIL_USERNAME= MAIL_PASSWORD= MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS= MAIL_FROM_NAME="Benotes" JWT_ALGO=HS256
Now we launch the container:
docker compose up -d
We need to allow read and write permissions on .env since it will be modified by the container to set the initial key.
sudo chmod 777 -env
Now we run this command to start the configuration:
docker compose exec --user application benotes_app sh
And we launch the configuration:
php artisan install
Now it will ask for confirmation to install, we answer yes to everything.
And it will ask to set the username, email, and password to access.
Onceready, we can access the service from http://localhost:8099
And now we can create a new collection and add our links or notes inside.