├── .github └── workflows │ └── test-platform.yml ├── .gitignore ├── LICENSE ├── README.md ├── backend.env ├── common.env ├── docker-compose.yml ├── replica_user.sql └── setup-e2e-db.sh /.github/workflows/test-platform.yml: -------------------------------------------------------------------------------- 1 | name: test-platform 2 | on: pull_request 3 | 4 | jobs: 5 | verify_pull_request: 6 | runs-on: ubuntu-latest 7 | 8 | steps: 9 | - uses: actions/checkout@v3 10 | - name: Build 11 | run: docker compose build 12 | - name: Run backend tests 13 | run: docker compose run api pytest 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020-2022, Saleor Commerce 4 | Copyright (c) 2020, Mirumee Software 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Saleor Platform](https://user-images.githubusercontent.com/249912/71523206-4e45f800-28c8-11ea-84ba-345a9bfc998a.png) 2 | 3 |
4 |

Saleor Platform

5 |
6 | 7 |
8 |

Run all Saleor services from one repository.

9 |
10 | 11 |
12 | 🏠 Website 13 | 14 | 📚 Docs 15 | 16 | 📰 Blog 17 | 18 | 🐦 Twitter 19 |
20 | 21 |
22 | 🔎 Explore Code 23 |
24 | 25 | ## About 26 | 27 | ### What is Saleor Platform? 28 | 29 | Saleor Platform is the easiest way to start local development with all the major Saleor services: 30 | - [Core GraphQL API](https://github.com/saleor/saleor) 31 | - [Dashboard](https://github.com/saleor/saleor-dashboard) 32 | - Mailpit (Test email interface) 33 | - Jaeger (APM) 34 | - The necessary databases, cache, etc. 35 | 36 | *Keep in mind this repository is for local development only and is not meant to be deployed in any production environment! If you're not a developer and just want to try out Saleor you can check our [live demo](https://demo.saleor.io/).* 37 | 38 | ## Requirements 39 | 1. [Docker](https://docs.docker.com/install/) 40 | 41 | ## How to clone the repository? 42 | 43 | To clone the repository, run the following command 44 | 45 | ``` 46 | git clone https://github.com/saleor/saleor-platform.git 47 | ``` 48 | 49 | ## How to run it? 50 | 51 | 1. Project is using shared folders to enable live code reloading. For `macOS` and `Windows` users following steps are required to run `Docker compose`: 52 | - Add the cloned `saleor-platform` directory to Docker shared directories (Preferences -> Resources -> File sharing). 53 | - In Docker preferences dedicate at least 5 GB of memory (Preferences -> Resources -> Advanced). 54 | 55 | 56 | 2. Go to the cloned directory: 57 | ```shell 58 | cd saleor-platform 59 | ``` 60 | 61 | 3. Apply Django migrations: 62 | ```shell 63 | docker compose run --rm api python3 manage.py migrate 64 | ``` 65 | 66 | 4. Populate the database with example data and create the admin user: 67 | ```shell 68 | docker compose run --rm api python3 manage.py populatedb --createsuperuser 69 | ``` 70 | *Note that `--createsuperuser` argument creates an admin account for `admin@example.com` with the password set to `admin`.* 71 | 72 | 5. Run the application: 73 | ```shell 74 | docker compose up 75 | ``` 76 | 77 | ## Where is the application running? 78 | - Saleor Core (API) - http://localhost:8000 79 | - Saleor Dashboard - http://localhost:9000 80 | - Jaeger UI (APM) - http://localhost:16686 81 | - Mailpit (Test email interface) - http://localhost:8025 82 | 83 | # Troubleshooting 84 | 85 | - [How to solve issues with lack of available space or build errors after an update](#how-to-solve-issues-with-lack-of-available-space-or-build-errors-after-an-update) 86 | - [How to run application parts?](#how-to-run-application-parts) 87 | 88 | ## How to solve issues with lack of available space or build errors after an update 89 | 90 | Most of the time both issues can be solved by cleaning up space taken by old containers. After that, we build again whole platform. 91 | 92 | 93 | 1. Make sure docker stack is not running 94 | ```shell 95 | docker compose stop 96 | ``` 97 | 98 | 2. Remove existing volumes 99 | 100 | **Warning!** Proceeding will remove also your database container! If you need existing data, please remove only services that cause problems! https://docs.docker.com/compose/reference/rm/ 101 | ```shell 102 | docker compose rm 103 | ``` 104 | 105 | 3. Build fresh containers 106 | ```shell 107 | docker compose build 108 | ``` 109 | 110 | 4. Now you can run a fresh environment using commands from `How to run it?` section. Done! 111 | 112 | ### Still no available space 113 | 114 | If you are getting issues with lack of available space, consider pruning your docker cache: 115 | 116 | **Warning!** This will remove: 117 | - all stopped containers 118 | - all networks not used by at least one container 119 | - all dangling images 120 | - all dangling build cache 121 | 122 | More info: https://docs.docker.com/engine/reference/commandline/system_prune/ 123 | 124 |
I've been warned 125 |

126 | 127 | ```shell 128 | docker system prune 129 | ``` 130 | 131 |

132 |
133 | 134 | ### Issues with migrations after changing the versions - resetting the database 135 | 136 | Please submit an issue ticket if you spot issues with database migrations during the version update. 137 | 138 | When testing developer releases or making local changes, you might end up in a state where you would like to reset the database completely. Since its state is persisted in the mounted volume, you'll need to use a dedicated command. 139 | 140 | **Warning!** This command will remove all data already stored in the database. 141 | 142 |
I've been warned 143 |

144 | 145 | ```shell 146 | docker compose down --volumes db 147 | ``` 148 | 149 |

150 |
151 | 152 | ## How to run application parts? 153 | - `docker compose up api worker` for backend services only 154 | - `docker compose up` for backend and frontend services 155 | 156 | ## Feedback 157 | 158 | If you have any questions or feedback, do not hesitate to contact us via [GitHub Discussions](https://github.com/saleor/saleor/discussions). 159 | 160 | ## License 161 | 162 | Disclaimer: Everything you see here is open and free to use as long as you comply with the [license](https://github.com/saleor/saleor-platform/blob/main/LICENSE). There are no hidden charges. We promise to do our best to fix bugs and improve the code. 163 | 164 | Some situations do call for extra code; we can cover exotic use cases or build you a custom e-commerce appliance. 165 | 166 | #### Crafted with ❤️ by [Saleor Commerce](https://saleor.io/) 167 | 168 | hello@saleor.io 169 | -------------------------------------------------------------------------------- /backend.env: -------------------------------------------------------------------------------- 1 | CELERY_BROKER_URL=redis://redis:6379/1 2 | DATABASE_URL=postgres://saleor:saleor@db/saleor 3 | DEFAULT_FROM_EMAIL=noreply@example.com 4 | EMAIL_URL=smtp://mailpit:1025 5 | SECRET_KEY=changeme 6 | OTEL_SERVICE_NAME=saleor 7 | OTEL_TRACES_EXPORTER=otlp 8 | OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4317 9 | -------------------------------------------------------------------------------- /common.env: -------------------------------------------------------------------------------- 1 | DEFAULT_CHANNEL_SLUG=default-channel 2 | # Note: recommended value is False for production usage, 3 | # refer to documentation for more details. 4 | HTTP_IP_FILTER_ALLOW_LOOPBACK_IPS=True 5 | # https://docs.saleor.io/docs/3.x/setup/configuration#http_ip_filter_enabled 6 | # Set to False to enable local apps development using docker host 7 | # Read more: https://docs.saleor.io/docs/3.x/developer/extending/apps/local-app-development 8 | # Note: recommended value for production is True 9 | HTTP_IP_FILTER_ENABLED=True 10 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | api: 3 | image: ghcr.io/saleor/saleor:3.21 4 | ports: 5 | - 8000:8000 6 | restart: unless-stopped 7 | networks: 8 | - saleor-backend-tier 9 | stdin_open: true 10 | tty: true 11 | depends_on: 12 | - db 13 | - redis 14 | - jaeger 15 | volumes: 16 | # shared volume between worker and api for media 17 | - saleor-media:/app/media 18 | env_file: 19 | - common.env 20 | - backend.env 21 | environment: 22 | - DASHBOARD_URL=http://localhost:9000/ 23 | - ALLOWED_HOSTS=localhost,api 24 | 25 | dashboard: 26 | image: ghcr.io/saleor/saleor-dashboard:latest 27 | ports: 28 | - 9000:80 29 | restart: unless-stopped 30 | 31 | db: 32 | image: library/postgres:15-alpine 33 | ports: 34 | - 5432:5432 35 | restart: unless-stopped 36 | networks: 37 | - saleor-backend-tier 38 | volumes: 39 | - saleor-db:/var/lib/postgresql/data 40 | - ./replica_user.sql:/docker-entrypoint-initdb.d/replica_user.sql:ro,z 41 | environment: 42 | - POSTGRES_USER=saleor 43 | - POSTGRES_PASSWORD=saleor 44 | 45 | redis: 46 | image: library/redis:7.0-alpine 47 | ports: 48 | - 6379:6379 49 | restart: unless-stopped 50 | networks: 51 | - saleor-backend-tier 52 | volumes: 53 | - saleor-redis:/data 54 | 55 | worker: 56 | image: ghcr.io/saleor/saleor:3.21 57 | command: celery -A saleor --app=saleor.celeryconf:app worker --loglevel=info -B 58 | restart: unless-stopped 59 | networks: 60 | - saleor-backend-tier 61 | env_file: 62 | - common.env 63 | - backend.env 64 | depends_on: 65 | - redis 66 | - mailpit 67 | volumes: 68 | # shared volume between worker and api for media 69 | - saleor-media:/app/media 70 | 71 | jaeger: 72 | image: jaegertracing/jaeger 73 | ports: 74 | - "16686:16686" 75 | - "4317:4317" 76 | - "4318:4318" 77 | restart: unless-stopped 78 | networks: 79 | - saleor-backend-tier 80 | volumes: 81 | - type: tmpfs 82 | target: /tmp 83 | 84 | mailpit: 85 | image: axllent/mailpit 86 | ports: 87 | - 1025:1025 # smtp server 88 | - 8025:8025 # web ui. Visit http://localhost:8025/ to check emails 89 | restart: unless-stopped 90 | networks: 91 | - saleor-backend-tier 92 | 93 | volumes: 94 | saleor-db: 95 | driver: local 96 | saleor-redis: 97 | driver: local 98 | saleor-media: 99 | 100 | networks: 101 | saleor-backend-tier: 102 | driver: bridge 103 | -------------------------------------------------------------------------------- /replica_user.sql: -------------------------------------------------------------------------------- 1 | -- Script being executed on DB init, creates read only user 2 | -- for replicas purposes. 3 | CREATE USER saleor_read_only WITH PASSWORD 'saleor'; 4 | GRANT CONNECT ON DATABASE saleor TO saleor_read_only; 5 | GRANT USAGE ON SCHEMA public TO saleor_read_only; 6 | GRANT SELECT ON ALL TABLES IN SCHEMA public TO saleor_read_only; 7 | ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO saleor_read_only; 8 | -------------------------------------------------------------------------------- /setup-e2e-db.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Script to load update-automation-snapshot into our database (to public schema) 3 | # It needs the docker compose from saleor platform repository: https://github.com/saleor/saleor-platform 4 | # Tested only on MacOs 5 | 6 | DIR="$( cd "$( dirname "$0" )" && pwd )" 7 | SNAPSHOT=$DIR"/update-automation-snapshot.sql" 8 | # make sure to use `public` schema 9 | sed -i '' 's/update_automation_snapshot_staging_saleor_cloud/public/' $SNAPSHOT 10 | sed -i '' 's/update_automation_snapshot_staging_saleor_cloud/public/' $SNAPSHOT 11 | 12 | # please note that you should not use this password on production services 13 | DB_URL="postgresql://saleor:saleor@localhost:5432/" 14 | # use different database for testing purpose 15 | FULL_DB_URL=$DB_URL"e2e" 16 | 17 | # drop previous database 18 | psql $DB_URL -c 'DROP DATABASE IF EXISTS e2e WITH(FORCE);' 19 | 20 | # create new database and make sure to install needed extensions 21 | psql $DB_URL -c 'CREATE DATABASE e2e;' 22 | psql $FULL_DB_URL -c 'CREATE EXTENSION IF NOT EXISTS btree_gin; CREATE EXTENSION IF NOT EXISTS pg_trgm;' 23 | 24 | # load the snapshot 25 | psql $FULL_DB_URL -f $SNAPSHOT 26 | 27 | # make sure to run migrations in case snapshot is not up to date with `core` migrations 28 | docker compose exec api python manage.py migrate 29 | --------------------------------------------------------------------------------