GitXplorerGitXplorer
s

strapi-traefik-https

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
ffec57b9ebcd98a636d63a74dc0f063cf0864a88

add backup readme

sstafyniaksacha committed 4 years ago
Unverified
f477543b97017748eac32ce19a69ba4b4a72e179

Merge branch 'master' of github.com:stafyniaksacha/strapi-traefik-https

sstafyniaksacha committed 4 years ago
Verified
a0c5d636cce7de7c2765b269af12391598137564

Update README.md

sstafyniaksacha committed 4 years ago
Unverified
ec26bd39f9a92deb72a79cc34156c775a5dec383

add backup script

sstafyniaksacha committed 4 years ago
Verified
9d767744e71109fac4578b22314de673eb6d22ab

Update README.md

sstafyniaksacha committed 4 years ago
Verified
7935e4697d6be545d3b00e2e838aa7ccd9f52857

Update README.md

sstafyniaksacha committed 4 years ago

README

The README file for this repository.

🔒 Strapi HTTPS with Traefik

Simple docker https configuration for strapi using traefik

🚀 Quickstart (6 steps)

  1. Clone this repository (or fork it)
git clone git@github.com:stafyniaksacha/strapi-traefik-https.git

cd ./strapi-traefik-https
  1. Create a new Strapi project in ./strapi folder
yarn create strapi-app strapi

or copy your project to ./strapi
or create a symlink to your existing project to ./strapi
or clone a git submodule into ./strapi

  1. Add strapi-connector-bookshelf and pg packages to strapi project
cd ./strapi

yarn add strapi-connector-bookshelf pg
  1. Update Strapi configuration
// ./strapi/config/database.js

module.exports = ({ env }) => ({
  defaultConnection: 'default',
  connections: {
    default: {
      connector: 'bookshelf',
      settings: {
        client: 'postgres',
        host: env('DATABASE_HOST', 'postgres'),
        port: env.int('DATABASE_PORT', 5432),
        database: env('DATABASE_NAME', 'postgresdb'),
        username: env('DATABASE_USERNAME', 'postgresuser'),
        password: env('DATABASE_PASSWORD', 'postgrespassword'),
      },
      options: {},
    },
  },
});
// ./strapi/config/server.js

module.exports = ({ env }) => ({
  host: env('HOST', '0.0.0.0'),
  port: env.int('PORT', 1337),
  url: `https://${env('STRAPI_URL', '127.0.0.1')}/`,
  admin: {
    auth: {
      secret: env('ADMIN_JWT_SECRET'),
    },
  }
});
  1. Create docker network
docker network create my-app-services
  1. Start the whole stack
docker-compose up

🎉 Access your services

Strapi admin: https://strapi.127.0.0.1.xip.io/admin
Traefik dashboard: https://traefik.127.0.0.1.xip.io/ (htpasswd auth: user/pass)

Traefik is binded to the host network:
using xip.io service allow us to have a wildcard dns pointing to 127.0.0.1

You can change ./traefik/htpasswd file to change http auth for traefik dashboard

🔄 Development with hotreload

  1. install node_modules from your host
yarn
  1. start your stack with docker-compose.dev.yml
CURRENT_UID=$(id -u):$(id -g) docker-compose -f docker-compose.dev.yml up

CURRENT_UID is used to bind your host user to the docker container user
so files created inside the container or outside remain the same (no fs erros !)

🚩 Environment variables

Name Default Description
HOST 127.0.0.1.xip.io main host for all services
DOCKER_SERVICES_RESTART no docker auto restart policy, can be always
POSTGRES_DB postgresdb postgres default database name
DATABASE_USERNAME postgresuser postgres default user name
DATABASE_PASSWORD postgrespassword postgres default user password
ADMIN_JWT_SECRET jwtsecret strapi admin jwt token (since 3.1.x)

📁 Create data backup

Generate a folder in ./backups directory containing:

  • strapi uploaded media ./backups/YYYYMMDD-HHmm/strapi_uploads.tar.gz
  • postgres dump ./backups/YYYYMMDD-HHmm/dump_postgres.sql
chmod +x ./backup.sh

./backup.sh