diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index eddde7883cb7946aa162d9568398e37dd060fb8c..c1101623274e3208a441bdea0c39a9c1687f63c8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,23 +1,28 @@
 image: docker:latest
 
 stages:
-  - test
   - build
+  - test
 
 test_api:
   stage: test
-  script:
+  before_script:
     - docker-compose -f api/test.yml build
+  script:
     - docker-compose -f api/test.yml run test
+  after_script:
+    - docker-compose -f api/test.yml run rm -rf api/funkwhale_api/media/*
 
   tags:
     - dind
 
 build_front:
   stage: build
+  before_script:
+    - docker-compose -f dev.yml run front rm dist/*
+    - docker-compose -f dev.yml build front
   script:
-    - docker-compose -f dev.yml front rm dist/*
-    - docker-compose -f dev.yml front npm run build
+    - docker-compose -f dev.yml run front npm run build
   artifacts:
     paths:
       - front/dist
diff --git a/api/test.yml b/api/test.yml
index e95461a7243ccf671bd4a6a54d144e1b0f363ead..dc50a9b545d75382531f2684de6cb7ed3925be78 100644
--- a/api/test.yml
+++ b/api/test.yml
@@ -1,7 +1,7 @@
 test:
   dockerfile: docker/Dockerfile.test
   build: .
-  entrypoint: python manage.py test
+  command: python manage.py test
   volumes:
     - .:/app
   environment: