From e67ad300c5c3e63fb124e2ed2554f89066a1ad81 Mon Sep 17 00:00:00 2001 From: Sho Kusano Date: Wed, 17 Apr 2019 00:42:27 +0900 Subject: [PATCH] Use original dockerfile --- .circleci/config.yml | 9 ++-- .dockerignore | 3 ++ Dockerfile.best-friends | 94 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 Dockerfile.best-friends diff --git a/.circleci/config.yml b/.circleci/config.yml index 3b2c91c0fee9c3..18d0ead816bbab 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -181,6 +181,8 @@ jobs: docker-build: docker: - image: circleci/python:3.6.4 + environment: + DOCKER_BUILDKIT: "1" working_directory: ~/projects/mastodon/ steps: - run: @@ -193,7 +195,8 @@ jobs: aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile default aws configure set region ${AWS_DEFAULT_REGION} --profile default - checkout - - setup_remote_docker + - setup_remote_docker: + version: 18.09.3 - run: name: Login to Amazon ECR command: | @@ -203,16 +206,14 @@ jobs: command: docker pull ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/mastodon:latest - run: name: Build docker image - command: docker build -t mastodon:latest --cache-from ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/mastodon:latest . + command: docker build -f Dockerfile.best-friends -t mastodon:latest --cache-from ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/mastodon:latest . - run: name: Push docker image to ECR command: | docker tag mastodon:latest ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/mastodon:latest docker tag mastodon:latest ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/mastodon:${CIRCLE_BRANCH} - docker tag mastodon:latest ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/mastodon:${CIRCLE_SHA1} docker push ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/mastodon:latest docker push ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/mastodon:${CIRCLE_BRANCH} - docker push ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/mastodon:${CIRCLE_SHA1} workflows: version: 2 diff --git a/.dockerignore b/.dockerignore index fca25fcff76ff5..cc25c2f8fb2f66 100644 --- a/.dockerignore +++ b/.dockerignore @@ -19,3 +19,6 @@ elasticsearch npm-debug.log yarn-error.log yarn-debug.log +/spec +/dist +/nanobox diff --git a/Dockerfile.best-friends b/Dockerfile.best-friends new file mode 100644 index 00000000000000..18904a01dd04b8 --- /dev/null +++ b/Dockerfile.best-friends @@ -0,0 +1,94 @@ +# syntax = docker/dockerfile:experimental + +ARG DEBIAN_RELEASE=stretch +ARG NODE_VERSION=8.15.1 +ARG RUBY_VERSION=2.6.1 + +FROM node:${NODE_VERSION}-${DEBIAN_RELEASE}-slim as node + +FROM ruby:${RUBY_VERSION}-slim-${DEBIAN_RELEASE} + +COPY --from=node /usr/local/ /usr/local/ + +ARG UID=991 +ARG GID=991 + +RUN \ + apt update && \ + echo "Etc/UTC" > /etc/localtime && \ + apt dist-upgrade -y && \ + apt install -y \ + build-essential \ + git \ + libicu-dev \ + libidn11-dev \ + libpq-dev \ + libprotobuf-dev \ + protobuf-compiler \ + && \ + apt install -y --no-install-recommends \ + bison \ + bzip2 \ + ca-certificates \ + ffmpeg \ + file \ + git \ + imagemagick \ + libffi-dev \ + libgdbm-dev \ + libgdbm3 \ + libgmp-dev \ + libicu-dev \ + libidn11 \ + libidn11-dev \ + libncurses5-dev \ + libpq-dev \ + libpq5 \ + libprotobuf-dev \ + libprotobuf10 \ + libreadline-dev \ + libreadline7 \ + libssl-dev \ + libssl1.1 \ + libxml2-dev \ + libxslt-dev \ + libyaml-0-2 \ + libyaml-dev \ + procps \ + protobuf-compiler \ + tzdata \ + whois \ + zlib1g-dev \ + && \ + gem install --no-document bundler && \ + rm /usr/local/bin/yarn /usr/local/bin/yarnpkg && \ + npm install --global --force yarn && \ + addgroup --gid $GID mastodon && \ + useradd -m -u $UID -g $GID -d /opt/mastodon mastodon && \ + echo "mastodon:`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 24 | mkpasswd -s -m sha-256`" | chpasswd && \ + mkdir -p /opt/mastodon && \ + chown mastodon:mastodon /opt/mastodon + +WORKDIR /opt/mastodon + +USER mastodon + +ADD --chown=mastodon:mastodon Gemfile* /opt/mastodon/ + +RUN \ + bundle config build.nokogiri --use-system-libraries && \ + bundle install -j$(nproc) --deployment --without development test + +ADD --chown=mastodon:mastodon package.json yarn.lock .yarnclean /opt/mastodon/ + +RUN \ + yarn install --pure-lockfile && \ + yarn cache clean + +COPY --chown=mastodon:mastodon . /opt/mastodon + +ENV RAILS_ENV=production +ENV NODE_ENV=production +ENV PATH=/opt/mastodon/bin:$PATH + +RUN OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile