From 65d9c304df06c46ed5e8bfd3d8bc53a84571684c Mon Sep 17 00:00:00 2001
From: Jun Kurihara <junkurihara@users.noreply.github.com>
Date: Sun, 5 Sep 2021 02:18:12 +0900
Subject: [PATCH] fix Dockerfile (#7763)

* fix Dockerfile

* remove unnecessary change

* add misskey-assets in .dockerignore
---
 .dockerignore |  2 +-
 Dockerfile    | 27 +++++++++------------------
 2 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/.dockerignore b/.dockerignore
index e16333fb2a..7cef84d940 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,5 +1,4 @@
 .autogen
-.git
 .github
 .travis
 .vscode
@@ -12,3 +11,4 @@ elasticsearch/
 node_modules/
 redis/
 files/
+misskey-assets/
diff --git a/Dockerfile b/Dockerfile
index 8c655c4c4f..58e3eda119 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,27 +4,17 @@ ENV NODE_ENV=production
 
 WORKDIR /misskey
 
+ENV BUILD_DEPS autoconf automake file g++ gcc libc-dev libtool make nasm pkgconfig python3 zlib-dev git
+
 FROM base AS builder
 
-RUN apk add --no-cache \
-    autoconf \
-    automake \
-    file \
-    g++ \
-    gcc \
-    libc-dev \
-    libtool \
-    make \
-    nasm \
-    pkgconfig \
-    python3 \
-    zlib-dev
-
-RUN git submodule update --init
-COPY package.json yarn.lock .yarnrc ./
-RUN yarn install
 COPY . ./
-RUN yarn build
+
+RUN apk add --no-cache $BUILD_DEPS && \
+    git submodule update --init && \
+    yarn install && \
+    yarn build && \
+    rm -rf .git
 
 FROM base AS runner
 
@@ -39,3 +29,4 @@ COPY --from=builder /misskey/built ./built
 COPY . ./
 
 CMD ["npm", "run", "migrateandstart"]
+
-- 
GitLab