├── env ├── localstack.env ├── secret │ └── .keep ├── postgres-96.env ├── dd-statsd.env ├── metaphysics.env └── force.env ├── .gitignore ├── scripts ├── setup.sh ├── debug.sh └── secrets.sh ├── docker └── localstack │ ├── Dockerfile │ └── entrypoint.sh ├── docker-compose.override.yml.template ├── LICENSE ├── README.md └── docker-compose.yml /env/localstack.env: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | docker-compose.override.yml 2 | env/secret/*.env 3 | -------------------------------------------------------------------------------- /env/secret/.keep: -------------------------------------------------------------------------------- 1 | # WARNING: Never commit any files in this folder 2 | -------------------------------------------------------------------------------- /scripts/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Refresh Secrets 6 | ./scripts/secrets.sh 7 | 8 | # Install docker for mac 9 | -------------------------------------------------------------------------------- /env/postgres-96.env: -------------------------------------------------------------------------------- 1 | PGDATA=/var/lib/postgresql/data/pgdata 2 | POSTGRES_USER=artsy 3 | POSTGRES_PASSWORD=artsy 4 | POSTGRES_HOST_AUTH_METHOD=trust 5 | -------------------------------------------------------------------------------- /docker/localstack/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM garland/aws-cli-docker:1.16.140 2 | 3 | RUN apk --update add bash 4 | 5 | COPY . . 6 | 7 | ENTRYPOINT ["./entrypoint.sh"] 8 | -------------------------------------------------------------------------------- /docker-compose.override.yml.template: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | force: 4 | image: tianon/true 5 | restart: 'no' 6 | exntrypoint: ['/true', '(DISABLED)'] 7 | -------------------------------------------------------------------------------- /scripts/debug.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | check_secrets() { 4 | echo "TODO: Implement" 5 | } 6 | 7 | check_aws() { 8 | echo "TODO: Implement" 9 | } 10 | 11 | check_datadog() { 12 | echo "TODO: Implement" 13 | } 14 | -------------------------------------------------------------------------------- /docker/localstack/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p ~/.aws 4 | touch ~/.aws/credentials 5 | touch ~/.aws/config 6 | 7 | echo "creating fake aws config files..." 8 | cat <> ~/.aws/credentials 9 | [local] 10 | aws_access_key_id = local 11 | aws_secret_access_key = local 12 | EOT 13 | 14 | cat <> ~/.aws/config 15 | [profile local] 16 | region = local 17 | EOT 18 | -------------------------------------------------------------------------------- /env/dd-statsd.env: -------------------------------------------------------------------------------- 1 | DD_HOSTNAME=local.monitoring 2 | DD_LOGS_STDOUT=yes 3 | DD_LOG_LEVEL=CRITICAL 4 | DD_TAGS=kube_region:local,kube_environment:local,kube_tier:artsy-local,kube_namespace:local 5 | DD_HISTOGRAM_PERCENTILES=0.95,0.99 6 | DD_APM_ENABLED=true 7 | DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true 8 | 9 | # If you would like to see real datadog statistics add a API key here. 10 | # DD_API_KEY=REPLACEME 11 | -------------------------------------------------------------------------------- /env/metaphysics.env: -------------------------------------------------------------------------------- 1 | # Service Dependencies 2 | ###################################################################### 3 | 4 | # Datadog 5 | ENABLE_QUERY_TRACING=false 6 | DD_TRACER_HOSTNAME=dd-statsd 7 | DD_TRACER_SERVICE_NAME=metaphysics-local 8 | STATSD_HOST=datadog 9 | 10 | # Memcached 11 | MEMCACHED_MAX_POOL=1000 12 | MEMCACHED_URL=memcached-16:11211 13 | 14 | # Service Configuration 15 | ###################################################################### 16 | 17 | # Feature flags 18 | # ENABLE_APOLLO=true 19 | # ENABLE_ASYNC_STACK_TRACES=false 20 | # ENABLE_COMMERCE_STITCHING=true 21 | # ENABLE_CONSIGNMENTS_STITCHING=true 22 | # ENABLE_KAWS_STITCHING=true 23 | # ENABLE_METRICS=false 24 | # ENABLE_QUERY_TRACING=false 25 | # ENABLE_REQUEST_LOGGING=true 26 | # ENABLE_RESOLVER_BATCHING=true 27 | # ENABLE_SCHEMA_STITCHING=true 28 | 29 | # Local Debug 30 | CACHE_DISABLED=true 31 | CACHE_QUERY_LOGGING_THRESHOLD_MS=1000 32 | RATE_LIMIT_MAX=0 33 | REQUEST_TIMEOUT_MS=5000 34 | RESOLVER_TIMEOUT_MS=0 35 | 36 | NODE_ENV=production 37 | -------------------------------------------------------------------------------- /env/force.env: -------------------------------------------------------------------------------- 1 | # Service Dependencies 2 | ###################################################################### 3 | 4 | # Redis 5 | OPENREDIS_URL=redis://redis-62:6379 6 | 7 | # Datadog 8 | DD_APM_ENABLED=false 9 | DD_SERVICE_NAME=artsy-local 10 | DD_TRACE_AGENT_HOSTNAME=dd-statsd 11 | 12 | # Metaphysics 13 | METAPHYSICS_ENDPOINT=http://metaphysics:3000 14 | 15 | # Service Configuration 16 | ###################################################################### 17 | APP_URL=http://local.artsy.net:5000 18 | APPLICATION_NAME=force-localhost 19 | CDN_URL= 20 | COOKIE_DOMAIN=local.artsy.net 21 | NODE_ENV=production 22 | PORT=5000 23 | 24 | # Feature Flags 25 | ENABLE_EXPERIMENTAL_STITCH_INJECTION=false 26 | ENABLE_INSTANT_PAGE=true 27 | ENABLE_MEMORY_PROFILING=true 28 | ENABLE_NEW_CONFIRM_BID_FORM=true 29 | ENABLE_PRICE_TRANSPARENCY=true 30 | ENABLE_SIGN_IN_WITH_APPLE=false 31 | EXPERIMENTAL_APP_SHELL=false 32 | 33 | # Session 34 | SESSION_COOKIE_KEY=artsy-local 35 | SESSION_COOKIE_MAX_AGE=63072000000 36 | SESSION_SECRET=artsylocal 37 | 38 | # Redis cache 39 | PAGE_CACHE_ENABLED=false 40 | -------------------------------------------------------------------------------- /scripts/secrets.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | SERVICES=( 6 | force 7 | gravity 8 | metaphysics 9 | ) 10 | 11 | function download() { 12 | echo "Retrieivng shared service secrets." 13 | 14 | for file in ${SERVICES[@]}; do 15 | if [[ ! -f "./env/secret/${file}.env" ]]; then 16 | echo "Downloading '${file}' secrets" 17 | aws s3 cp --quiet "s3://artsy-citadel/dev/.env.${file}" "./env/secret/${file}.env" 18 | else 19 | aws s3 cp --quiet "s3://artsy-citadel/dev/.env.${file}" "/tmp/artsy-local/secret/${file}.env" 20 | 21 | CURRENT_HASH=$(shasum "./env/secret/${file}.env" | cut -f 1 -d ' ') 22 | NEW_HASH=$(shasum "/tmp/artsy-local/secret/${file}.env" | cut -f 1 -d ' ') 23 | 24 | if [[ "${CURRENT_HASH}" != "${NEW_HASH}" ]]; then 25 | echo "Refreshing '${file}' secrets" 26 | mv -f "/tmp/artsy-local/secret/${file}.env" "./env/secret/${file}.env" 27 | else 28 | echo "'${file}' secrets up-to-date" 29 | fi 30 | 31 | fi 32 | done 33 | rm -rf "/tmp/artsy-local" 34 | unset file 35 | } 36 | 37 | download 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Artsy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # artsy-local 2 | 3 | This repo contains the necessary docker-compose configurations to run everything 4 | Artsy on your local machine in Docker. 5 | 6 | ### Step One: Clone the **artsy-local** git repo: 7 | 8 | ```bash 9 | $ git clone git@github.com:artsy/artsy-local.git 10 | ``` 11 | 12 | ### Step Two: Environment Configuration 13 | 14 | You'll need several environment variables in your `~/.bash_profile` or `~/.zshrc` file. 15 | 16 | ```bash 17 | export AWS_ACCESS_KEY_ID= 18 | export AWS_SECRET_ACCESS_KEY= 19 | export AWS_DEFAULT_REGION=us-east-1 20 | export AWS_ACCOUNT_ID= 21 | ``` 22 | 23 | - `AWS_ACCESS_KEY_ID` - Part of your credentials for accessing AWS Resources 24 | - `AWS_SECRET_ACCESS_KEY` - Part of your credentials for accessing AWS Resources 25 | - `AWS_DEFAULT_REGION` - The aws region commands will execute in. 26 | - `AWS_ACCOUNT_ID` - The account id associated with your aws account, find it [here](https://docs.aws.amazon.com/IAM/latest/UserGuide/console_account-alias.html) 27 | 28 | After you've configured your AWS credentials its time to authenticate with ECR. Restart your shell and run the following command. 29 | 30 | ``` 31 | aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com 32 | ``` 33 | 34 | ### Step Three: Run Setup 35 | 36 | Ensure that Docker is installed on your system using the proper instructions from their [website](https://docs.docker.com/get-docker/) 37 | 38 | **NOTE: If you are running on a Mac you should adjust your memory and cpu allocations as the default will be to low** 39 | 40 | Finally, run the setup script. 41 | 42 | ```bash 43 | ./scripts/setup.sh 44 | ``` 45 | 46 | ### Step Four: Starting All Services 47 | 48 | Run `docker-compose up -d` from your terminal to start all of the services. 49 | 50 | As many services are being booted up at the same time in this step, your host might 51 | have a hard time allocating resources. If you run into issues, try 52 | `docker-compose up -d` one more time. 53 | 54 | ### Step Five: Installing the ssl certificate 55 | 56 | ** TODO: add ssl instructions** 57 | 58 | ## Step Six: Login 59 | 60 | ** TODO: verify login** 61 | 62 | ## Mocking specific stack dependencies 63 | 64 | ## Running a partial stack 65 | 66 | ## Adding a new Service 67 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | ################### 4 | # Operations 5 | ################### 6 | # dd-statsd: 7 | # container_name: dd-statsd 8 | # image: datadog/docker-dd-agent:latest 9 | # restart: unless-stopped 10 | # ports: 11 | # - 8125:8125/udp 12 | # volumes: 13 | # - /var/run/docker.sock:/var/run/docker.sock:ro 14 | # env_file: 15 | # - ./env/dd-statsd.env 16 | 17 | #################### 18 | # Core Services 19 | #################### 20 | force: 21 | container_name: force 22 | image: ${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/force:production 23 | ports: 24 | - 5000:5000 25 | env_file: 26 | - ./env/secret/force.env 27 | - ./env/force.env 28 | depends_on: 29 | - redis-62 30 | 31 | metaphysics: 32 | container_name: metaphysics 33 | image: ${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/metaphysics:production 34 | ports: 35 | - 3000:3000 36 | env_file: 37 | - ./env/secret/metaphysics.env 38 | - ./env/metaphysics.env 39 | depends_on: 40 | - memcached-14 41 | 42 | # gravity: 43 | # container_name: gravity 44 | # image: ${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/gravity:production 45 | # env_file: 46 | # - ./env/secret/gravity.env 47 | 48 | #################### 49 | # Data Services 50 | #################### 51 | redis-62: 52 | container_name: redis-62 53 | image: redis:6.2.3 54 | ports: 55 | - "6379:6379" 56 | volumes: 57 | - redis-62:/data 58 | 59 | memcached-14: 60 | container_name: memcached-14 61 | image: memcached:1.4.34 62 | ports: 63 | - "11211:11211" 64 | 65 | # mongo-50: 66 | # container_name: mongo-50 67 | # hostname: mongo-50 68 | # image: mongo:5.0.5 69 | # ports: 70 | # - "27017:27017" 71 | # volumes: 72 | # - mongo-50:/data/db 73 | 74 | # postgres-96: 75 | # container_name: postgres-96 76 | # image: postgres:9.6 77 | # env_file: 78 | # - ./env/postgres-96.env 79 | # ports: 80 | # - "5432:5432" 81 | # volumes: 82 | # - postgres-96:/var/lib/postgresql/data 83 | 84 | # elasticsearch: 85 | # image: docker.elastic.co/elasticsearch/elasticsearch:6.4.2 86 | # container_name: elasticsearch 87 | # environment: 88 | # - cluster.name=docker-cluster 89 | # - bootstrap.memory_lock=true 90 | # - "ES_JAVA_OPTS=-Xms512m -Xmx512m" 91 | # ulimits: 92 | # memlock: 93 | # soft: -1 94 | # hard: -1 95 | # volumes: 96 | # - esdata:/usr/share/elasticsearch/data 97 | # ports: 98 | # - 9200:9200 99 | 100 | localstack: 101 | container_name: localstack 102 | image: localstack/localstack:0.14.0 103 | env_file: 104 | - ./env/localstack.env 105 | ports: 106 | - "4567-4584:4567-4584" 107 | - "8042:8080" 108 | volumes: 109 | - "/var/run/docker.sock:/var/run/docker.sock" 110 | 111 | localstack-setup: 112 | container_name: localstack-setup 113 | build: 114 | context: ./docker/localstack 115 | env_file: 116 | - ./env/localstack.env 117 | depends_on: 118 | - localstack 119 | 120 | volumes: 121 | redis-62: 122 | # mongo-50: 123 | # postgres-96: 124 | # esdata: 125 | 126 | 127 | --------------------------------------------------------------------------------