• Stars
    star
    1,153
  • Rank 38,873 (Top 0.8 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Install and run your first Strapi project using Docker

Strapi containerized

⚠️ This image is only for Strapi v3. For now, we will not update it for v4.

However, to build an image compatible with Strapi v4, we recommend you check out this tool created by the Strapi Community: https://github.com/strapi-community/strapi-tool-dockerize


Strapi

API creation made simple, secure and fast. The most advanced open-source Content Management Framework to build powerful API with no effort.


Travis Docker Pulls

Images

Strapi comes with two images: strapi/strapi and strapi/base.

Use strapi/strapi to create a new project or run a project on your host machine.

Use strapi/base to build a Dockerfile and create an image for your app.

How to use strapi/strapi

This image allows you to create a new strapi project or run a project from your host machine. The default command that will run in your project is strapi develop.

Creating a new project

When running this image, strapi will check if there is a project in the /srv/app folder of the container. If there is nothing then it will run the strapi new command in the container /srv/app folder. You can create a new project by running this command.

docker run -it -p 1337:1337 -v `pwd`/project-name:/srv/app strapi/strapi

This command creates a project with an SQLite database. Then starts it on port 1337.

The -v option creates a project-name folder on your computer that will be shared with the docker container. Once the project is created it will be available in this folder on your computer.

Environment variables

When creating a new project with this image you can pass database configurations to the strapi new command.

  • DATABASE_CLIENT a database provider supported by Strapi: (sqlite, postgres, mysql ,mongo).
  • DATABASE_HOST database host.
  • DATABASE_PORT database port.
  • DATABASE_NAME database name.
  • DATABASE_USERNAME database username.
  • DATABASE_PASSWORD database password.
  • DATABASE_SSL boolean for SSL.
  • EXTRA_ARGS pass extra args to the strapi new.

Example

You can create a strapi project that will connect to a remote postgres database like so:

docker run -it \
  -e DATABASE_CLIENT=postgres \
  -e DATABASE_NAME=strapi \
  -e DATABASE_HOST=0.0.0.0 \
  -e DATABASE_PORT=5432 \
  -e DATABASE_USERNAME=strapi \
  -e DATABASE_PASSWORD=strapi \
  -p 1337:1337 \
  -v `pwd`/project-name:/srv/app \
  strapi/strapi

You can also create projects using docker-compose. See examples of using these variables with docker-compose in the examples folder.

Running a project from your host machine

You can also use strapi/strapi to run a project you already have created (or cloned for a repo) on your computer.

First make sure to delete the node_modules folder if you have already installed your dependencies on your host machine. Then run:

cd my-project
docker run -it -p 1337:1337 -v `pwd`:/srv/app strapi/strapi

This will start by installing the dependencies and then run strapi develop in the project.

Environment variables

If you are using environment variables in your code you can pass them with the -e option (e.g docker run -e ENV_VAR=sth ...).

You can for example set your database configuration with environment variables. Because the default container command is strapi develop you will need to update your development database configuration following the production example in the documentation. Then you can run:

docker run -it \
  -e DATABASE_NAME=strapi \
  -e DATABASE_HOST=0.0.0.0 \
  -e DATABASE_PORT=1234 \
  -e DATABASE_USERNAME=strapi \
  -e DATABASE_PASSWORD=strapi \
  -p 1337:1337 \
  -v `pwd`/project-name:/srv/app \
  strapi/strapi

Upgrading Strapi in Docker container

  • Important! Upgrading strapi/strapi Docker image tag does not upgrade Strapi version.
    • Strapi NodeJS application builds itself during first startup only, if detects empty folder and is normally stored in mounted volume. See docker-entrypoint.sh.
  • To upgrade, first follow the guides (general and version-specific) to rebuild actual Strapi NodeJS application. Secondly, update docker tag to match the version to avoid confusion.

How to use strapi/base

When deploying a strapi application to production you can use docker to package your whole app in an image. You can create a Dockerfile in your strapi project like the one in ./examples/custom

Building the images in this repository

You can build the images with the build command. To see the options run:

yarn install
./bin/build.js --help

More Repositories

1

strapi

🚀 Strapi is the leading open-source headless CMS. It’s 100% JavaScript/TypeScript, fully customizable and developer-first.
TypeScript
59,511
star
2

strapi-examples

🎓 List of examples using Strapi
1,339
star
3

foodadvisor

🥘 THE Strapi demo application
JavaScript
1,017
star
4

documentation

Strapi Documentation
JavaScript
917
star
5

nextjs-corporate-starter

Strapi Demo application for Corporate Websites using Next.js
TypeScript
784
star
6

community-content

Contribute and collaborate on educational content for the Strapi Community
JavaScript
562
star
7

buffet

Buffet.js — React Components Library made with styled-components
JavaScript
536
star
8

design-system

Strapi.io's design system 🚀
TypeScript
412
star
9

strapi-starter-next-blog

Strapi Starter Next Blog
JavaScript
377
star
10

strapi-starter-next-corporate

Next.js starter for creating a corporate site with Strapi.
JavaScript
344
star
11

starters-and-templates

Monorepo for all official Strapi v4 templates
JavaScript
308
star
12

strapi-sdk-javascript

🔌 Official JavaScript SDK for APIs built with Strapi.
TypeScript
270
star
13

strapi-starter-next-ecommerce

Strapi Starter Next.js E-commerce
JavaScript
210
star
14

strapi-starter-nuxt-blog

Strapi Starter Nuxt Blog
Vue
181
star
15

strapi-starter-nuxt-e-commerce

Strapi Starter Nuxt.js E-commerce
Vue
177
star
16

strapi-starter-gatsby-blog

Updated version of the first Gatsby starter with much more features
JavaScript
139
star
17

strapi-starter-react-blog

Strapi Starter React Blog
JavaScript
120
star
18

strapi-legacy-gatsby-blog

Strapi Starter Gatsby Blog
JavaScript
101
star
19

strapi-legacy-blog

Starter for creating a simple blog with Strapi.
JavaScript
96
star
20

strapi-heroku-template

Strapi official template for Heroku 1 click deploy button
JavaScript
93
star
21

strapi-template-corporate

Template to create Strapi projects pre-configured for corporate sites
JavaScript
83
star
22

strapi-plugin-seo

The official plugin to make your Strapi content SEO friendly
JavaScript
81
star
23

rfcs

RFCs for Strapi future changes
69
star
24

waterline-graphql

GraphQL adapter for the Waterline ORM.
JavaScript
69
star
25

strapi-starter-angular-blog

Strapi Starter Angular Blog
TypeScript
66
star
26

strapi-starter-vue-blog

Strapi Starter Vue Blog
Vue
64
star
27

strapi-next-14-dashboard-demo

TypeScript
60
star
28

strapi-template-blog

Template to create Strapi projects pre-configured for blogs
JavaScript
60
star
29

strapi-template-ecommerce

Template to create Strapi projects pre-configured for e-commerce apps
JavaScript
58
star
30

migration-scripts

Collection of Strapi Migration scripts
JavaScript
57
star
31

blocks-react-renderer

A React renderer for the Strapi's Blocks rich text editor
TypeScript
57
star
32

one-click-deploy

Shell
56
star
33

codemods

A set of scripts to help migrate Strapi plugins (and in some cases Strapi applications) from v3 to v4
JavaScript
42
star
34

strapi-heroku-cms-demo

Repository for "CMS" from the Gatsby / Strapi Video Tuturial Series
JavaScript
35
star
35

strapi-starter-gridsome-blog

Build blog sites using Strapi and Gridsome
Vue
32
star
36

strapi-starter-gridsome-portfolio

Build portfolio sites using Strapi and Gridsome
Vue
32
star
37

strapi-starter-gatsby-catalog

Strapi Starter Gatsby Catalog
JavaScript
27
star
38

strapi-starter-gatsby-corporate

JavaScript
26
star
39

strapi-docs

The Strapi documentation.
24
star
40

strapi-template-event-vercel

Template to create Strapi projects pre-configured for event using the Vercel Event kit
JavaScript
22
star
41

strapi-conf-next-template

TypeScript
20
star
42

strapi-plugin-open-ai

The official plugin that allows you to create Open AI completion from a prompt
JavaScript
16
star
43

strapi-meetups

Learn, share and collaborate with the community at Strapi meetups. Contributions welcome.
15
star
44

bookshelf-cache-redis

🔥 A robust, performance-focused caching solution for Bookshelf based on top of Redis.
JavaScript
15
star
45

strapi-studio

The official open-source repository of the Strapi Studio.
12
star
46

strapi-generate-admin

Generate the default admin panel inside your Strapi application.
JavaScript
12
star
47

community-resources

Explore and learn a diverse range of ways to contribute to the Strapi Community
11
star
48

strapi-conf-admin-template

Template for the StrapiConf Admin
JavaScript
10
star
49

strapi-template-portfolio

Template to create Strapi projects pre-configured for portfolio sites
JavaScript
10
star
50

strapi-plugin-gatsby-preview

JavaScript
9
star
51

components

Official Strapi components library
9
star
52

strapi-generate-users

Generate user features for your Strapi application.
JavaScript
8
star
53

strapi-generate-upload

Generate the default upload features for a Strapi application.
JavaScript
6
star
54

strapi-generate-email

Generate the default email features for a Strapi application.
JavaScript
6
star
55

eslint-config

Strapi eslint config
JavaScript
6
star
56

strapi-template-next-example

JavaScript
5
star
57

.github

Community health files for the @strapi organization
4
star
58

strapi-template-catalog

JavaScript
4
star
59

strapi-settings-manager

Strapi plugin built to let you easily configure your Strapi applications.
JavaScript
3
star
60

best-practices-samples

Sample project code for Strapi Best Practice calls
JavaScript
3
star
61

security-patches

Patch-package patches for TID2212
2
star
62

plugin-rfc-examples

JavaScript
2
star
63

strapi-generate

JavaScript
2
star
64

strapi-generate-api

JavaScript
2
star
65

strapi-generate-new

JavaScript
2
star
66

javascript

Strapi Javascript Style Guide
1
star
67

foodadvisor-migration-example

JavaScript
1
star
68

internal-lms

Strapi's Internal Learning Management System
JavaScript
1
star
69

strapi-cloud-template-blog

JavaScript
1
star