From ad031e0347d6687fd70351e3ca00212a613532cf Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Fri, 3 Jun 2022 19:26:28 +0800 Subject: [PATCH] updated Dockerfile --- .github/workflows/docker-crawlab.yml | 4 ++-- Dockerfile | 8 +++++--- backend/Dockerfile | 6 +++++- bin/docker-install-plugins.sh | 25 ------------------------- frontend/Dockerfile | 7 ++++++- 5 files changed, 18 insertions(+), 32 deletions(-) delete mode 100644 bin/docker-install-plugins.sh diff --git a/.github/workflows/docker-crawlab.yml b/.github/workflows/docker-crawlab.yml index 10f644dc..3bd66861 100644 --- a/.github/workflows/docker-crawlab.yml +++ b/.github/workflows/docker-crawlab.yml @@ -87,7 +87,7 @@ jobs: cd $IMAGE_PATH_CRAWLAB_BACKEND docker build . --file Dockerfile --tag image - name: Log into registry - run: echo ${{ secrets.DOCKER_PASSWORD}} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin + run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin - name: Push image run: | IMAGE_VERSION=${{needs.setup.outputs.version}} @@ -109,7 +109,7 @@ jobs: cd $IMAGE_PATH_CRAWLAB_FRONTEND docker build . --file Dockerfile --tag image - name: Log into registry - run: echo ${{ secrets.DOCKER_PASSWORD}} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin + run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin - name: Push image run: | IMAGE_VERSION=${{needs.setup.outputs.version}} diff --git a/Dockerfile b/Dockerfile index 18053697..d05fbee4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,8 @@ FROM crawlabteam/crawlab-backend:latest AS backend-build FROM crawlabteam/crawlab-frontend:latest AS frontend-build +FROM crawlabteam/crawlab-public-plugins:latest AS public-plugins-build + # images FROM crawlabteam/crawlab-base:latest @@ -18,11 +20,11 @@ RUN cp /opt/bin/crawlab /usr/local/bin/crawlab-server # copy frontend files COPY --from=frontend-build /app/dist /app/dist +# copy public-plugins files +COPY --from=public-plugins-build /app/plugins /app/plugins + # copy nginx config files COPY ./nginx/crawlab.conf /etc/nginx/conf.d -# install plugins -RUN /bin/bash /app/bin/docker-install-plugins.sh - # start backend CMD ["/bin/bash", "/app/bin/docker-init.sh"] diff --git a/backend/Dockerfile b/backend/Dockerfile index 497cd804..65c0894a 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.16 +FROM golang:1.16 AS build WORKDIR /go/src/app COPY . . @@ -9,3 +9,7 @@ ENV GO111MODULE on RUN go mod tidy \ && go install -v ./... +FROM alpine:3.14 + +# copy files +COPY --from=backend-build /go/bin/crawlab /go/bin/crawlab diff --git a/bin/docker-install-plugins.sh b/bin/docker-install-plugins.sh deleted file mode 100644 index 9135fc74..00000000 --- a/bin/docker-install-plugins.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -function install_plugin() { - # plugins executables directory - local bin_path="/app/plugins/bin" - if [ -d $bin_path ]; then - : - else - mkdir -p "$bin_path" - fi - - # plugin name - local name=$1 - local url="https://github.com/crawlab-team/${name}" - local repo_path=""/app/plugins/${name} - git clone "$url" "$repo_path" - cd "$repo_path" && go build -o "${bin_path}/${name}" - chmod +x "${bin_path}/${name}" -} - -plugin_names="plugin-dependency plugin-notification plugin-spider-assistant" - -for name in $plugin_names; do - install_plugin "$name" -done diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 97b83d37..6e9e1fae 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,4 +1,4 @@ -FROM node:12 +FROM node:12 AS build ADD . /app WORKDIR /app @@ -6,3 +6,8 @@ RUN rm /app/.npmrc # install frontend RUN yarn install && yarn run build:docker + +FROM alpine:3.14 + +# copy files +COPY --from=build /app/dist /app/dist