diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 649e7a3..9e966e9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ image: docker:stable stages: +- build frontend - build - manifest @@ -8,13 +9,33 @@ default: before_script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY +build frontend: + image: node:lts-alpine + stage: build frontend + before_script: [] + variables: + NODE_ENV: "production" + cache: + paths: + - maubot/management/frontend/node_modules + script: + - cd maubot/management/frontend + - yarn --prod + - yarn build + - mv build ../../../frontend + artifacts: + paths: + - frontend + expire_in: 1 hour + build amd64: stage: build tags: - amd64 script: + - echo frontend >> .dockerignore - docker pull $CI_REGISTRY_IMAGE:latest || true - - docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 . + - docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 . -f Dockerfile.ci - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 - docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 @@ -23,8 +44,9 @@ build arm64: tags: - arm64 script: + - echo frontend >> .dockerignore - docker pull $CI_REGISTRY_IMAGE:latest || true - - docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 . + - docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 . -f Dockerfile.ci - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 - docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 diff --git a/Dockerfile b/Dockerfile index aa7fc9d..02e222c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,33 +5,36 @@ RUN cd /frontend && yarn --prod && yarn build FROM alpine:3.11 -ENV UID=1337 \ - GID=1337 +COPY requirements.txt /opt/maubot/requirements.txt +WORKDIR /opt/maubot +RUN apk add --no-cache --virtual .build-deps \ + python3-dev \ + build-base \ + git \ + && apk add --no-cache \ + ca-certificates \ + su-exec \ + py3-aiohttp \ + py3-sqlalchemy \ + py3-attrs \ + py3-bcrypt \ + py3-cffi \ + py3-pillow \ + py3-magic \ + py3-psycopg2 \ + py3-ruamel.yaml \ + py3-jinja2 \ + py3-click \ + py3-packaging \ + py3-markdown \ + && pip3 install -r requirements.txt \ + feedparser dateparser langdetect python-gitlab \ + && apk del .build-deps +# TODO remove pillow, magic and feedparser when maubot supports installing dependencies COPY . /opt/maubot COPY --from=frontend-builder /frontend/build /opt/maubot/frontend -WORKDIR /opt/maubot -RUN apk add --no-cache \ - py3-aiohttp \ - py3-sqlalchemy \ - py3-attrs \ - py3-bcrypt \ - py3-cffi \ - build-base \ - python3-dev \ - ca-certificates \ - su-exec \ - py3-pillow \ - py3-magic \ - py3-psycopg2 \ - py3-ruamel.yaml \ - py3-jinja2 \ - py3-click \ - py3-packaging \ - py3-markdown \ - && pip3 install -r requirements.txt feedparser dateparser langdetect python-gitlab -# TODO remove pillow, magic and feedparser when maubot supports installing dependencies - +ENV UID=1337 GID=1337 VOLUME /data CMD ["/opt/maubot/docker/run.sh"] diff --git a/Dockerfile.ci b/Dockerfile.ci new file mode 100644 index 0000000..2aac70d --- /dev/null +++ b/Dockerfile.ci @@ -0,0 +1,34 @@ +FROM alpine:3.11 + +COPY requirements.txt /opt/maubot/requirements.txt +WORKDIR /opt/maubot +RUN apk add --no-cache --virtual .build-deps \ + python3-dev \ + build-base \ + git \ + && apk add --no-cache \ + ca-certificates \ + su-exec \ + py3-aiohttp \ + py3-sqlalchemy \ + py3-attrs \ + py3-bcrypt \ + py3-cffi \ + py3-pillow \ + py3-magic \ + py3-psycopg2 \ + py3-ruamel.yaml \ + py3-jinja2 \ + py3-click \ + py3-packaging \ + py3-markdown \ + && pip3 install -r requirements.txt \ + feedparser dateparser langdetect python-gitlab \ + && apk del .build-deps +# TODO remove pillow, magic and feedparser when maubot supports installing dependencies + +COPY . /opt/maubot +ENV UID=1337 GID=1337 +VOLUME /data + +CMD ["/opt/maubot/docker/run.sh"]