More Premium Hugo Themes Premium Nextjs Themes

Strapi Nextjs Docker Boilerplate

Boilerplate for building Dockerized applications using Strapi v4 + Next.js + Postgres +Nginx

Strapi Nextjs Docker Boilerplate

Boilerplate for building Dockerized applications using Strapi v4 + Next.js + Postgres +Nginx

Author Avatar Theme by buraste
Github Stars Github Stars: 84
Last Commit Last Commit: Jul 23, 2022 -
First Commit Created: Dec 18, 2023 -
default image

Overview

This package is currently under development and is considered in the beta state. It aims to provide an easy development and production environment, as well as easy adoption of frontend technologies. It is designed for creating full-stack applications for small or medium-sized projects.

Features

  • Backend: Utilizes Strapi v4, Node.js v16 for Docker Image, and Yarn package manager.
  • Frontend: Built with Next.js v12.2, React.js v18.2, Typescript v4.7, Node.js-alpine for Docker Image, and Yarn package manager.
  • Database: Incorporates Postgres v12-alpine, Linux/amd64 platform for platform error on Apple M1 chips, and named volumes.
  • Reverse Proxy: Uses Nginx Latest with fastcgi support and mime-types security configs.
  • Containerization: Implements Docker-compose v3 for container orchestration. Consists of separated Dockerfiles for development and production.
  • Environment Variables Management: One file for backend, frontend, database, and Nginx.

Installation

To use this package, you need to have Docker and Docker Compose installed on your system. Follow these steps:

  1. Clone the repository.
  2. Copy the .env.example file to .env.
  3. Change the credentials in the .env file to secure and strong ones.
  4. If you are on development, ensure that ENVIRONMENT=development is set in the .env file. If you are on production or want to production build, change it to ENVIRONMENT=production.
  5. Make sure localhost:80 is accessible and not being used by another process (Nginx runs on port 80).
  6. Pull the necessary images.

Usage

To build and start the docker-compose file, follow these steps:

  1. Run the command docker-compose up if everything is okay.
  2. Access the Next.js frontend at http://localhost.
  3. Access the Strapi backend (admin) at http://localhost/strapi/admin.
  4. Register with your email and password.
  5. Go to the Content-Type Builder, which has a sample content type named “Article” with three fields: title, body, and cover.
  6. To create a new Article, go to the Content Manager, click on Article in the left pane, then click Create new entry and fill in the details. Finally, click Publish!
  7. To test the API endpoint, you need to give public access to the Article. Go to Settings > User & Permissions Plugin > Roles > Public > Article and select find and findOne. If you need more permissions, select the desired ones and save.
  8. Access the API endpoint at http://localhost/strapi/api/articles.

Security for Endpoints

To secure all your Strapi-related endpoints in Nginx, make sure to use API tokens to connect to the backend and keep this information private. Note that the Nginx configuration provided in the repository is for development purposes and not suitable for production.

Contributing

Contributions are welcome to help shape this package. If interested, please feel free to email the maintainer, Burak, at hello@buraste.com.

Authors

  • Burak Ibis
    • Github: @buraste
    • Twitter: @helloburaste

License

See the LICENSE file for licensing information.