version: 2 jobs: test-backend: docker: - image: circleci/node:14 - image: circleci/mariadb:latest environment: MYSQL_ALLOW_EMPTY_PASSWORD: "true" MYSQL_DATABASE: photos_test MYSQL_USER: photos MYSQL_PASSWORD: photos MYSQL_HOST: "localhost" working_directory: ~/photos steps: - checkout - restore_cache: keys: - backend-dependencies-{{ checksum "package.json" }} - run: name: install backend deps command: npm i - save_cache: paths: - node_modules key: backend-dependencies-{{ checksum "package.json" }} - run: name: test backend command: npm test test-frontend: docker: - image: circleci/node:14 working_directory: ~/photos/frontend steps: - checkout: - restore_cache: keys: - backend-dependencies-{{ checksum "package.json" }} - run: name: install backend deps command: npm i - save_cache: paths: - node_modules key: backend-dependencies-{{ checksum "package.json" }} - restore_cache: keys: - frontend-dependencies-{{ checksum "package.json" }} - run: name: install frontend deps command: cd frontend && npm i - save_cache: paths: - frontend/node_modules key: frontend-dependencies-{{ checksum "package.json" }} - run: name: test frontend command: cd frontend && npm test test-frontend-build: docker: - image: circleci/node:14 working_directory: ~/photos/frontend steps: - checkout: - restore_cache: keys: - backend-dependencies-{{ checksum "package.json" }} - run: name: install backend deps command: npm i - save_cache: paths: - node_modules key: backend-dependencies-{{ checksum "package.json" }} - restore_cache: keys: - frontend-dependencies-{{ checksum "package.json" }} - run: name: install frontend deps command: cd frontend && npm i - save_cache: paths: - frontend/node_modules key: frontend-dependencies-{{ checksum "package.json" }} - run: name: build frontend command: cd frontend && npm run build build: machine: image: ubuntu-2004:202107-01 working_directory: ~/photos steps: - checkout - run: name: log in to docker hub command: echo "$DOCKER_PASSWORD" | docker login --username $DOCKER_USERNAME --password-stdin - run: name: install emulators command: docker run --privileged --rm tonistiigi/binfmt --install all - run: name: create docker builder command: docker buildx create --use - run: name: build and push to docker hub #command: docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag stepanusatiuk/photos:latest . command: docker buildx build --push --platform linux/amd64 --tag stepanusatiuk/photos:latest . workflows: version: 2 test-build: jobs: - test-backend - test-frontend - test-frontend-build: requires: - test-frontend - build: requires: - test-backend - test-frontend - test-frontend-build