Implement CI/CD

This commit is contained in:
Daniel_I_Am 2022-05-28 12:36:45 +00:00
parent edf132c168
commit 0afc9c27af
8 changed files with 82 additions and 24 deletions

57
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,57 @@
stages:
- "Install Dependencies"
- "Lint Code"
- "Build Docker Image"
- "Publish Docker Image"
"Install node_modules":
image: node:16
stage: "Install Dependencies"
script:
- yarn --frozen-lockfile
artifacts:
paths:
- node_modules/
"Lint JS":
image: node:16
stage: "Lint Code"
dependencies:
- "Install node_modules"
script:
- yarn lint --no-fix
"Build docker image":
image: docker:stable
stage: "Build Docker Image"
tags:
- docker
- hawkeye
dependencies:
- "Install node_modules"
- "Lint JS"
script:
# Add make support
- 'apk add --no-cache make'
# Build the image
- 'make build-container DOCKER_REPOSITORY=$REGISTRY_BASE_URL/$DOCKER_IMAGE_NAME DOCKER_TAG=$CI_COMMIT_SHA'
rules:
- if: '$CI_COMMIT_REF_PROTECTED == "true"'
"Publish Docker Image":
image: docker:stable
stage: "Publish Docker Image"
tags:
- docker
- hawkeye
dependencies:
- "Build docker image"
script:
# Log in to the registry
- 'docker login -u=$REGISTRY_USER -p=$REGISTRY_PASSWORD $REGISTRY_BASE_URL'
# Push the registry images
- 'docker image push $REGISTRY_BASE_URL/$DOCKER_IMAGE_NAME:$CI_COMMIT_SHA'
# Clean local image
- 'docker image rm $REGISTRY_BASE_URL/$DOCKER_IMAGE_NAME:$CI_COMMIT_SHA'
rules:
- if: '$CI_COMMIT_REF_PROTECTED == "true"'

View File

@ -1,4 +1,4 @@
DOCKER_REPOSITORY := daniel-website/nginx
DOCKER_REPOSITORY?="daniel-website/nginx"
DOCKER_TAG?="dev"
.DEFAULT_GOAL := help

View File

@ -5,7 +5,7 @@ WORKDIR /code
USER node
RUN yarn
RUN yarn --frozen-lockfile
RUN yarn build
FROM nginx:1.22.0-alpine

View File

@ -1,5 +1,6 @@
[
{
"id": 1,
"title": "Seconds since last pacman sync",
"slug": "seconds-since-last-pacman-sync",
"timeAdded": 1652993100,

View File

@ -2276,9 +2276,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001332, caniuse-lite@^1.0.30001335:
version "1.0.30001343"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001343.tgz"
integrity sha512-8KeCrAtPMabo/XW14B+R9sZYoClx1n0b+WYgwDKZPtWR3TcdvWzdSy7mPyFEmR5WU1St9v1PW6sdO5dkFOEzfA==
version "1.0.30001344"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001344.tgz"
integrity sha512-0ZFjnlCaXNOAYcV7i+TtdKBp0L/3XEU2MF/x6Du1lrh+SRX4IfzIVL4HNJg5pB2PmFb8rszIGyOvsZnqqRoc2g==
case-sensitive-paths-webpack-plugin@^2.3.0:
version "2.4.0"