The following steps take you through the required steps to install, build, and run the project locally.
- Download and install Docker to your computer (verify with
Docker -v
anddocker-compose -v
in a terminal). - Download and install Node to your computer so tht we can install our node packages (verify with
npm -v
in a terminal). - Clone this repository using
git clone <url>
or your favorite git client. - In a terminal, navigate to the repository directory that you just cloned.
- Run
docker-compose build
to build all of the required Docker images for the project. - Run
npm install
in the same directory to install all dependencies for the front end app (this is run locally, and not in the container, so that files may be edited in real time and updated in the container). - Once that is done, run
docker-compose up
to start all of the Docker containers (database, strapi, and app).- NOTE: if this is your first time starting, this may take several minutes.
- NOTE: windows users may have to type
net stop http
to use port 80
There won't be anything in the database or backend yet, so you have to import a schema and data to start off with a running project.
Steps
- Verify you have Node installed with
node -v
in a terminal. - Ensure that the project is running successfully (using previous steps) by seeing this in the Strapi Docker container logs. If you do not see this yet, then it is possible the container is still starting up.
-
One more thing... Create your first administrator 💻 by going to the administration panel at: ┌─────────────────────────────┐ │ http://localhost:1337/admin │ └─────────────────────────────┘
-
NOTE: DON'T OPEN YOUR BROWSER YET - the scripts will handle admin account (credentials in last step) creation for you.
-
NOTE: if this is your first time starting, this may take several minutes.
-
- Run
npm run import
to import all of the required data for project. - Launch the Strapi admin panel (i.e. localhost:1337) to see the new content types and imported data! The username is
admin
and the password iscapstone
for the Strapi admin panel.
If you want more control over what is imported, you can run the specific import scripts to have more control. Why would you want to do this?
- Import different exports/schemas/data during testing
- Avoid overwriting data that is in your database, Strapi, or uploads
- Restore specific backup file
Steps
- With the project running successfully, navigate to the database folder of the project (i.e.
cd database
in project root). - Run
node import-strapi.js <strapi-export-file>
to import a Strapi schema of content types. - Run
node import-database.js <database-export-file>
to import the database content that matches the Strapi schema content types. - Run
node import-uploads.js <uploads-export-file>
to import the file uploads (i.e. images) into the Strapi container. - Each of the scripts take a file as the argument for where to import the data from. These files must come from a data export. For example files, see the
BaseExport
files which is what thenpm run import
script uses.
NOTE: You can run any import over and over again. The Strapi import creates and updates what is needed. The uploads import does not delete any newly added data, it just creates or overwrites files. However, the database import is a destructive operation due to the database dump constraints.
Once you have the project running locally, you may make changes to the project that will require exporting. Why would you want to do this?
- Create backups and check points
- Persist Strapi content type schema changes in Git
- Persist database changes in Git
- Persist uploads (images) changes in Git
- Manipulate project schema and data without fear of losing something that works
All of the imports use files created by exporting.
Steps
- With the project running successfully, in the project directory, run
npm run export
to export all of the current data from Strapi, the database, and the file uploads into their own export files, all named variants ofBaseExport
. - Export created! Running
npm run import
will restore/import this export.
Steps
- With the project running successfully, navigate to the database folder of the project (i.e.
cd database
in project root). - Run
node export-strapi.js <filename>
to export all of the current content types in your Strapi container. You must give the export a filename for it to be created. File format is.json
. - Run
node export-database.js <filename>
to export the Strapi database data. You must give the export a filename for it to be created. File format is.zip
. - Run
node export-uploads.js <filename>
to export the Strapi file uploads data (i.e. images for the sponsors or users). You must give the export a filename for it to be created. File format is.zip
. - These three files will be created in the current directory under the given filenames and can be used to in an import on an running instance of the project.