Merge branch '166-setup-dev-ci-cd' into 'develop'
Draft: Resolve "setup dev CI/CD" See merge request framasoft/framadate/funky-framadate-front!81
This commit is contained in:
commit
1af5ceae98
|
@ -0,0 +1,8 @@
|
||||||
|
.angular/
|
||||||
|
node_modules/
|
||||||
|
dist/
|
||||||
|
docs/
|
||||||
|
e2e/
|
||||||
|
**/*.log
|
||||||
|
**/.DS_Store
|
||||||
|
**/Thumbs.db
|
|
@ -1,16 +1,19 @@
|
||||||
# image: weboaks/node-karma-protractor-chrome
|
# image: weboaks/node-karma-protractor-chrome
|
||||||
image: node:16
|
# image: node:16
|
||||||
|
include:
|
||||||
|
- "kaniko-build.gitlab-ci.yml"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
|
- deploy
|
||||||
# - pages
|
# - pages
|
||||||
# - test
|
# - test
|
||||||
# - e2e
|
# - e2e
|
||||||
|
|
||||||
cache:
|
# cache:
|
||||||
paths:
|
# paths:
|
||||||
- node_modules/
|
# - node_modules/
|
||||||
- .yarn
|
# - .yarn
|
||||||
|
|
||||||
#pages:
|
#pages:
|
||||||
# stage: pages
|
# stage: pages
|
||||||
|
@ -37,14 +40,39 @@ cache:
|
||||||
# cache:
|
# cache:
|
||||||
# policy: pull
|
# policy: pull
|
||||||
|
|
||||||
build:
|
build-image:
|
||||||
stage: build
|
stage: build
|
||||||
before_script:
|
tags:
|
||||||
- yarn
|
- docker
|
||||||
|
extends: .kaniko_build
|
||||||
|
variables:
|
||||||
|
PUSH_IMAGE: "true"
|
||||||
|
REGISTRY_PATH: "${HARBOR_HOST}/${HARBOR_PROJECT}"
|
||||||
|
REGISTRY_IMAGE_PATH: "${REGISTRY_PATH}/${CI_PROJECT_NAME}:develop"
|
||||||
|
only:
|
||||||
|
- develop
|
||||||
|
|
||||||
|
deploy-image:
|
||||||
|
stage: deploy
|
||||||
|
image:
|
||||||
|
name: bitnami/kubectl:latest
|
||||||
|
entrypoint: ['']
|
||||||
script:
|
script:
|
||||||
- yarn run build:prod
|
- kubectl config get-contexts
|
||||||
cache:
|
- kubectl config use-context framasoft/framadate/funky-framadate-front:framadate-cluster
|
||||||
policy: pull
|
- kubectl -n framadate rollout restart deployments/frontend-deployment
|
||||||
|
only:
|
||||||
|
- develop
|
||||||
|
|
||||||
|
# build:
|
||||||
|
# image: node:16
|
||||||
|
# stage: build
|
||||||
|
# before_script:
|
||||||
|
# - yarn
|
||||||
|
# script:
|
||||||
|
# - yarn run build:prod
|
||||||
|
# cache:
|
||||||
|
# policy: pull
|
||||||
|
|
||||||
#e2e:
|
#e2e:
|
||||||
# stage: e2e
|
# stage: e2e
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
# Create stage to build angular application
|
||||||
|
FROM node:18.15.0-alpine AS angular-builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package.json .
|
||||||
|
|
||||||
|
RUN yarn install
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN yarn run build:prod
|
||||||
|
|
||||||
|
# Build NGINX Image to serve builded files
|
||||||
|
FROM nginx:stable-alpine
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN rm -rf /usr/share/nginx/html/*
|
||||||
|
|
||||||
|
COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
# Copy dist folder fro build stage to nginx public folder
|
||||||
|
COPY --from=angular-builder /app/dist/framadate /app
|
||||||
|
|
||||||
|
# Start NgInx service
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
|
@ -0,0 +1,58 @@
|
||||||
|
worker_processes 1;
|
||||||
|
error_log /var/log/nginx/error.log warn;
|
||||||
|
pid /tmp/nginx.pid;
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
http {
|
||||||
|
client_body_temp_path /tmp/client_temp;
|
||||||
|
proxy_temp_path /tmp/proxy_temp_path;
|
||||||
|
fastcgi_temp_path /tmp/fastcgi_temp;
|
||||||
|
uwsgi_temp_path /tmp/uwsgi_temp;
|
||||||
|
scgi_temp_path /tmp/scgi_temp;
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||||
|
'$status $body_bytes_sent "$http_referer" '
|
||||||
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||||
|
access_log /var/log/nginx/access.log main;
|
||||||
|
sendfile on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_static on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_proxied no-cache no-store private expired auth;
|
||||||
|
gzip_min_length 10240;
|
||||||
|
gzip_types
|
||||||
|
application/javascript
|
||||||
|
application/json
|
||||||
|
font/woff2
|
||||||
|
text/css
|
||||||
|
text/plain;
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
location / {
|
||||||
|
root /app;
|
||||||
|
index index.html;
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
error_page 500 502 503 504 /50x.html;
|
||||||
|
location = /50x.html {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
}
|
||||||
|
location ~* (\.html|\/sw\.js)$ {
|
||||||
|
root /app;
|
||||||
|
expires -1y;
|
||||||
|
add_header Pragma "no-cache";
|
||||||
|
add_header Cache-Control "public";
|
||||||
|
}
|
||||||
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|json)$ {
|
||||||
|
root /app;
|
||||||
|
expires 1y;
|
||||||
|
add_header Cache-Control "public, immutable";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
# FROM https://gitlab.cern.ch/ci-tools/container-image-ci-templates/
|
||||||
|
|
||||||
|
# Defining the variables which can be overridden while using the template file in .gitlab-ci.yml
|
||||||
|
# REGISTRY_IMAGE_PATH: Defines where the image should be pushed to.
|
||||||
|
# CONTEXT_DIR: Defines the context dir for the image build
|
||||||
|
# DOCKER_FILE_NAME: Defines the name of the Dockerfile
|
||||||
|
# PUSH_IMAGE: If the gitlab step should push the built image
|
||||||
|
# BUILD_ARGS: The build-time variables
|
||||||
|
|
||||||
|
variables:
|
||||||
|
CONTEXT_DIR: ""
|
||||||
|
DOCKER_FILE_NAME: "Dockerfile"
|
||||||
|
GIT_SUBMODULE_STRATEGY: recursive
|
||||||
|
PUSH_IMAGE: "false"
|
||||||
|
BUILD_ARGS: ""
|
||||||
|
|
||||||
|
.kaniko_build:
|
||||||
|
stage: build
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
image:
|
||||||
|
# Using the official kaniko v1.6 image for the builds
|
||||||
|
name: gcr.io/kaniko-project/executor:v1.6.0-debug
|
||||||
|
entrypoint: [""]
|
||||||
|
script:
|
||||||
|
- |
|
||||||
|
if [ -z "${REGISTRY_IMAGE_PATH}" ]; then
|
||||||
|
echo "ERROR: CI variable REGISTRY_IMAGE_PATH is mandatory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
- REGISTRY=$(echo ${REGISTRY_IMAGE_PATH} | cut -d / -f 1)
|
||||||
|
- >
|
||||||
|
if [ -z "${CONTEXT_DIR}" ]; then
|
||||||
|
KANIKO_CONTEXT_DIR=${CI_PROJECT_DIR}
|
||||||
|
else
|
||||||
|
KANIKO_CONTEXT_DIR=${CI_PROJECT_DIR}/${CONTEXT_DIR}
|
||||||
|
fi
|
||||||
|
- mkdir -p /kaniko/.docker
|
||||||
|
- |
|
||||||
|
if [ -z "$DOCKER_AUTH_CONFIG" ]; then
|
||||||
|
# build the DOCKER_AUTH_CONFIG from user parameters as per https://docs.gitlab.com/ee/ci/docker/using_kaniko.html and internal docs
|
||||||
|
echo "{\"auths\":{\"${HARBOR_HOST}\":{\"auth\":\"$(printf "%s:%s" "${HARBOR_USERNAME}" "${HARBOR_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
|
||||||
|
else
|
||||||
|
echo "${DOCKER_AUTH_CONFIG}" > /kaniko/.docker/config.json
|
||||||
|
fi
|
||||||
|
# build and push the image to the path set in $REGISTRY_IMAGE_PATH variable.
|
||||||
|
- |
|
||||||
|
if [ "$(echo ${PUSH_IMAGE} | tr '[:upper:]' '[:lower:]')" = "true" ]; then
|
||||||
|
PUSH_IMAGE=""
|
||||||
|
else
|
||||||
|
echo "Info: defer pushing image to remote as PUSH_IMAGE is false"
|
||||||
|
PUSH_IMAGE="--no-push"
|
||||||
|
fi
|
||||||
|
- |
|
||||||
|
if [ -n "$BUILD_ARGS" ]; then
|
||||||
|
for arg in $BUILD_ARGS; do
|
||||||
|
KANIKO_BUILD_ARGS="${KANIKO_BUILD_ARGS} --build-arg ${arg}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
- /kaniko/executor
|
||||||
|
--cache=true
|
||||||
|
--cache-repo=${REGISTRY_PATH}/cache
|
||||||
|
--context "${KANIKO_CONTEXT_DIR}"
|
||||||
|
--dockerfile "${DOCKER_FILE_PATH}/${DOCKER_FILE_NAME}" ${KANIKO_BUILD_ARGS}
|
||||||
|
--destination "${REGISTRY_IMAGE_PATH}" "${PUSH_IMAGE}"
|
||||||
|
--use-new-run
|
||||||
|
--single-snapshot
|
||||||
|
--snapshotMode=redo
|
||||||
|
--skip-unused-stages
|
Loading…
Reference in New Issue