Optimize CI and dockerfile caching
This commit is contained in:
parent
293b44729c
commit
9a777ee451
@ -1,6 +1,7 @@
|
|||||||
image: docker:stable
|
image: docker:stable
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- build frontend
|
||||||
- build
|
- build
|
||||||
- manifest
|
- manifest
|
||||||
|
|
||||||
@ -8,13 +9,33 @@ default:
|
|||||||
before_script:
|
before_script:
|
||||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
- 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:
|
build amd64:
|
||||||
stage: build
|
stage: build
|
||||||
tags:
|
tags:
|
||||||
- amd64
|
- amd64
|
||||||
script:
|
script:
|
||||||
|
- echo frontend >> .dockerignore
|
||||||
- docker pull $CI_REGISTRY_IMAGE:latest || true
|
- 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 push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
|
||||||
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
|
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
|
||||||
|
|
||||||
@ -23,8 +44,9 @@ build arm64:
|
|||||||
tags:
|
tags:
|
||||||
- arm64
|
- arm64
|
||||||
script:
|
script:
|
||||||
|
- echo frontend >> .dockerignore
|
||||||
- docker pull $CI_REGISTRY_IMAGE:latest || true
|
- 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 push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
|
||||||
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
|
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
|
||||||
|
|
||||||
|
51
Dockerfile
51
Dockerfile
@ -5,33 +5,36 @@ RUN cd /frontend && yarn --prod && yarn build
|
|||||||
|
|
||||||
FROM alpine:3.11
|
FROM alpine:3.11
|
||||||
|
|
||||||
ENV UID=1337 \
|
COPY requirements.txt /opt/maubot/requirements.txt
|
||||||
GID=1337
|
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 . /opt/maubot
|
||||||
COPY --from=frontend-builder /frontend/build /opt/maubot/frontend
|
COPY --from=frontend-builder /frontend/build /opt/maubot/frontend
|
||||||
WORKDIR /opt/maubot
|
ENV UID=1337 GID=1337
|
||||||
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
|
|
||||||
|
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
|
|
||||||
CMD ["/opt/maubot/docker/run.sh"]
|
CMD ["/opt/maubot/docker/run.sh"]
|
||||||
|
34
Dockerfile.ci
Normal file
34
Dockerfile.ci
Normal file
@ -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"]
|
Loading…
Reference in New Issue
Block a user