Skip to content

Docker on Apple M1 (ARM64)

Patrick Trumpis edited this page Feb 22, 2024 · 11 revisions

Important Note

This issue has been fixed with Snap Camera Server v3.2.0 and above.
Use the following instructions with v3.1.x and below only.


Click to view old fix

Running Docker with Apple M1/M2 (ARM64) chip

If you try to run docker compose up on an Apple computer with M1/M2 chip, you will probably get an error and you will have to manually update your docker-compose.yml file.

Edit your docker-compose.yml file and add the entry platform: linux/amd64 to the MySQL service or any other service that produces an error.

docker-compose.yml

version: '3.8'

services:
  mysql:
    platform: linux/amd64
    image: mysql:5.7
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=${MYSQL_DATABASE}
    ports:
      - ${MYSQL_LOCAL_PORT}:${MYSQL_DOCKER_PORT}
    volumes:
      - db:/var/lib/mysql
      - ./mysql:/docker-entrypoint-initdb.d:ro

  adminer:
    image: adminer
    environment:
      - ADMINER_DEFAULT_SERVER=mysql
      - ADMINER_DESIGN=${ADMINER_DESIGN}
    ports:
      - ${ADMINER_LOCAL_PORT}:${ADMINER_DOCKER_PORT}
    depends_on:
      - mysql

  webproxy:
    image: nginx
    environment:
      - WEBAPP_PORT=${APP_DOCKER_PORT}
      - HTTP_PORT=${NGINX_DOCKER_PORT}
      - WWW_ROOT=${NGINX_WWW_ROOT}
    volumes:
      - ./ssl/studio-app.snapchat.com.crt:/etc/ssl/certs/studio-app.snapchat.com.crt:ro
      - ./ssl/studio-app.snapchat.com.key:/etc/ssl/private/studio-app.snapchat.com.key:ro
      - ./nginx/default.conf.template:/etc/nginx/templates/default.conf.template:ro
      - ./nginx/theme:/etc/nginx/theme:ro
      - ./nginx/snap-camera-categories-media:${NGINX_WWW_ROOT}/snap-camera-categories-media:ro
      - ./nginx/snap-camera-media:${NGINX_WWW_ROOT}/snap-camera-media:ro
      - ./nginx/snap-camera-media-alt:${NGINX_WWW_ROOT}/snap-camera-media-alt:ro
      - ./import:${NGINX_WWW_ROOT}/import
      - storage:${NGINX_WWW_ROOT}
    ports:
      - ${NGINX_LOCAL_PORT}:${NGINX_DOCKER_PORT}
      - 443:443
    depends_on:
      - webapp

  webapp:
    build: .
    environment:
      - DB_HOST=mysql
      - DB_USER=${MYSQL_USER}
      - DB_PASS=${MYSQL_ROOT_PASSWORD}
      - DB_NAME=${MYSQL_DATABASE}
      - DB_PORT=${MYSQL_DOCKER_PORT}
      - PORT=${APP_DOCKER_PORT}
      - STORAGE_SERVER=http://studio-app.snapchat.com:${NGINX_LOCAL_PORT}
      - STORAGE_PATH=/var/lib/snapcamera
      - IMPORT_DIR=import
      - MEDIA_DIR=snap-camera-media
      - MEDIA_DIR_ALT=snap-camera-media-alt
    volumes:
      # content of snap-camera-media (MEDIA_DIR) is not getting included automatically through storage
      - ./nginx/snap-camera-media:/var/lib/snapcamera/snap-camera-media:ro
      - ./import:/var/lib/snapcamera/import
      - ./:/usr/src/app
      - /usr/src/app/node_modules
      - storage:/var/lib/snapcamera
    ports:
      - ${APP_LOCAL_PORT}:${APP_DOCKER_PORT}
    depends_on:
      - mysql

volumes:
  storage:
    name: server-storage
  db:
    name: mysql-db

Example docker-compose.yml file for Snap Camera Server v3.1

Info

If your changes have no effect, try to run these commands:

docker compose down
docker compose up --build