Build a docker container storing only the frontent assets
* Run as part of gitlab:assets:compile job * Will be used by omnibus-gitlab and the CNG images to avoid compiling multiple times https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22235
This commit is contained in:
parent
86d8fd86a7
commit
70ee4e1b3e
3 changed files with 33 additions and 0 deletions
|
@ -694,7 +694,10 @@ gitlab:setup-mysql:
|
|||
# Frontend-related jobs
|
||||
gitlab:assets:compile:
|
||||
<<: *dedicated-no-docs-and-no-qa-pull-cache-job
|
||||
image: dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.4.4-git-2.18-chrome-69.0-node-8.x-yarn-1.2-graphicsmagick-1.3.29-docker-18.06.1
|
||||
dependencies: []
|
||||
services:
|
||||
- docker:stable-dind
|
||||
variables:
|
||||
NODE_ENV: "production"
|
||||
RAILS_ENV: "production"
|
||||
|
@ -703,18 +706,23 @@ gitlab:assets:compile:
|
|||
WEBPACK_REPORT: "true"
|
||||
# we override the max_old_space_size to prevent OOM errors
|
||||
NODE_OPTIONS: --max_old_space_size=3584
|
||||
DOCKER_DRIVER: overlay2
|
||||
DOCKER_HOST: tcp://docker:2375
|
||||
script:
|
||||
- date
|
||||
- yarn install --frozen-lockfile --production --cache-folder .yarn-cache
|
||||
- date
|
||||
- free -m
|
||||
- bundle exec rake gitlab:assets:compile
|
||||
- scripts/build_assets_image
|
||||
artifacts:
|
||||
name: webpack-report
|
||||
expire_in: 31d
|
||||
paths:
|
||||
- webpack-report/
|
||||
- public/assets/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
karma:
|
||||
<<: *dedicated-no-docs-pull-cache-job
|
||||
|
|
4
Dockerfile.assets
Normal file
4
Dockerfile.assets
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Simple container to store assets for later use
|
||||
FROM scratch
|
||||
ADD public/assets /assets/
|
||||
CMD /bin/true
|
21
scripts/build_assets_image
Executable file
21
scripts/build_assets_image
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Generate the image name based on the project this is being run in
|
||||
ASSETS_IMAGE_NAME=$(echo ${CI_PROJECT_NAME} |
|
||||
awk '{
|
||||
split($1, p, "-");
|
||||
interim = sprintf("%s-assets-%s", p[1], p[2]);
|
||||
sub(/-$/, "", interim);
|
||||
print interim
|
||||
}'
|
||||
)
|
||||
|
||||
ASSETS_IMAGE_PATH=${CI_REGISTRY}/${CI_PROJECT_PATH}/${ASSETS_IMAGE_NAME}
|
||||
|
||||
mkdir -p assets_container.build/public
|
||||
cp -r public/assets assets_container.build/public/
|
||||
cp Dockerfile.assets assets_container.build/
|
||||
docker build -t ${ASSETS_IMAGE_PATH}:${CI_COMMIT_REF_NAME} -f assets_container.build/Dockerfile.assets assets_container.build/
|
||||
docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
|
||||
docker push ${ASSETS_IMAGE_PATH}
|
||||
|
Loading…
Reference in a new issue