mr_incredible
mr_incredible

Reputation: 1115

How to clear cache in GitLab CI?

In the docs I've learned that I can clear cache by including cache: {} into my gitlab-ci.yml file like so:

enter image description here

I must be using it wrong though because this is what I read in build output:

enter image description here

I've got problem with this because few lines down I replaced npm ci with npm install --no-optional and the GitLab runner keeps calling npm ci

Any suggestions ?

Dockerfile:

###########
# BUILDER #
###########

FROM node:11.12.0-alpine as builder

WORKDIR /usr/src/app

ENV PATH /usr/src/app/node_modules/.bin:$PATH
COPY package.json /usr/src/app/package.json
COPY package-lock.json /usr/src/app/package-lock.json
RUN npm install --no-optional
RUN npm install [email protected] -g --silent --no-optional
ARG REACT_APP_USERS_SERVICE_URL
ENV REACT_APP_USERS_SERVICE_URL $REACT_APP_USERS_SERVICE_URL
ARG NODE_ENV
ENV NODE_ENV $NODE_ENV


COPY . /usr/src/app
RUN npm run build

Upvotes: 3

Views: 13772

Answers (3)

stackprotector
stackprotector

Reputation: 13451

As has been pointed out already, GitLab CI cache and Docker cache are not the same. To clear the Docker cache, login to the GitLab Runner and execute:

sudo docker system prune -a

Upvotes: 0

Sjoerd
Sjoerd

Reputation: 75609

To clear the cache in GitLab CI, click the "Clear runner caches" on the CI/CD Pipelines page. This increases a counter in the cache key, effectively using new caches for everything.

See also this issue: Clearing the cache (#41249) · Issues · GitLab.org / GitLab FOSS · GitLab

Upvotes: 3

Nicolas Pepinster
Nicolas Pepinster

Reputation: 6221

docker cache and gitlab-ci cache are different things.

Lines you point out in red are lines produced during docker build command. Gitlab-ci cache option is used to specify a list of files and directories which should be cached between jobs.

To avoid using cache during docker build, use --no-cache option (see the documentation for more details)

Upvotes: 3

Related Questions