Compare commits

...

6 Commits

Author SHA1 Message Date
rinsuki
33e2ccd809 refactor(docker.cross): packages/client の yarn install はnativeじゃないほうではしない 2022-04-16 01:03:24 +09:00
rinsuki
b803279b2a build by every dockerfiles, for compare 2022-04-16 00:38:28 +09:00
rinsuki
fb388d77f6 Add Dockerfile.cross 2022-04-16 00:38:28 +09:00
rinsuki
ebc0303d7c no need to login 2022-04-16 00:38:28 +09:00
rinsuki
a2f157b5c4 下準備: 無条件でbuildだけする 2022-04-16 00:38:28 +09:00
potpro
b38665fcb3 Update docker.yml 2022-04-16 00:38:28 +09:00
4 changed files with 108 additions and 6 deletions

36
.github/workflows/docker-build.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: Build Docker image
on:
push:
pull_request:
workflow_dispatch:
jobs:
build:
name: Build Docker Image
runs-on: ubuntu-latest
strategy:
matrix:
dockerfile: [Dockerfile, Dockerfile.cross]
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: misskey/misskey
- name: Build
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ${{ matrix.dockerfile }}

View File

@ -13,6 +13,10 @@ jobs:
steps: steps:
- name: Check out the repo - name: Check out the repo
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker meta - name: Docker meta
id: meta id: meta
uses: docker/metadata-action@v3 uses: docker/metadata-action@v3
@ -27,6 +31,7 @@ jobs:
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: . context: .
platforms: linux/amd64,linux/arm64
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}

59
Dockerfile.cross Normal file
View File

@ -0,0 +1,59 @@
FROM --platform=$BUILDPLATFORM node:16.6.2-alpine3.13 AS native_base
ENV NODE_ENV=production
WORKDIR /misskey
ENV BUILD_DEPS autoconf automake file g++ gcc libc-dev libtool make nasm pkgconfig python3 zlib-dev git
# yarn cache を TARGETPLATFORM のステージ類で早く使いたいので yarn install までで一旦 stage を分ける
FROM native_base AS native_cache_builder
COPY . ./
RUN apk add --no-cache $BUILD_DEPS && \
yarn install
FROM native_cache_builder as native_builder
RUN git submodule update --init && \
yarn build && \
rm -rf .git
# ---
FROM node:16.6.2-alpine3.13 AS base
ENV NODE_ENV=production
WORKDIR /misskey
ENV BUILD_DEPS autoconf automake file g++ gcc libc-dev libtool make nasm pkgconfig python3 zlib-dev git
COPY . ./
# build dependencies package
FROM base as deps_builder
RUN apk add --no-cache $BUILD_DEPS
COPY --from=native_cache_builder /usr/local/share/.cache/yarn /usr/local/share/.cache/yarn
RUN SKIP_CLIENT=YES yarn install
FROM base AS runner
RUN apk add --no-cache \
ffmpeg \
tini
ENTRYPOINT ["/sbin/tini", "--"]
# $(yarn cache dir) on container
COPY --from=deps_builder /misskey/node_modules ./node_modules
COPY --from=deps_builder /misskey/packages/backend/node_modules ./packages/backend/node_modules
COPY --from=native_builder /misskey/packages/backend/built ./packages/backend/built
COPY --from=native_builder /misskey/built ./built
CMD ["npm", "run", "migrateandstart"]

View File

@ -9,11 +9,13 @@ const execa = require('execa');
stderr: process.stderr, stderr: process.stderr,
}); });
console.log('installing dependencies of packages/client ...'); if (process.env.SKIP_CLIENT !== "YES") {
console.log('installing dependencies of packages/client ...');
await execa('yarn', ['install'], { await execa('yarn', ['install'], {
cwd: __dirname + '/../packages/client', cwd: __dirname + '/../packages/client',
stdout: process.stdout, stdout: process.stdout,
stderr: process.stderr, stderr: process.stderr,
}); });
}
})(); })();