Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SRC_PATH=src
BUILD_PATH=build
CV=cv
25 changes: 25 additions & 0 deletions .github/actions/build_image/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Build docker image"
description: "Action to build docker image"
inputs:
image:
description: "image:tag"
required: true
dockerfile:
description: "Dockerfile to use"
required: true
default: "Dockerfile"
target:
description: "target to build"
required: false
default: ""
context:
description: "context"
required: true
default: "."
outputs: {}
runs:
using: "composite"
steps:
- run: |
docker build -t ${{ inputs.image }} -f ${{ inputs.dockerfile }} --target ${{ inputs.target }} ${{ inputs.context }}
shell: bash
23 changes: 23 additions & 0 deletions .github/workflows/build_all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build all variants of docker images
on:
push: {}

jobs:
build:
strategy:
matrix:
base_image:
- ubuntu
target:
- builder
- release
runs-on: ubuntu-latest
steps:
- name: Check out Project
uses: actions/checkout@v3

- name: build
uses: ./.github/actions/build_image
with:
image: ${{ matrix.target }}:${{ matrix.base_image }}
target: ${{ matrix.target }}
40 changes: 40 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI workflow
on:
push: {}
workflow_dispatch:
inputs:
tag:
default: latest
description: image tag

jobs:
build:
runs-on: ubuntu-latest
env:
BUILDER_IMAGE: cv-builder
RELEASE_IMAGE: cv
TAG: "${{ inputs.tag != '' && inputs.tag || github.ref_name }}"
BASE_IMAGE: "${{ inputs.base_image != '' && inputs.base_image || 'ubuntu' }}"
steps:
- name: Check out Project
uses: actions/checkout@v3

- name: Build builder image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: false
tags: ${{ env.BUILDER_IMAGE }}:${{ env.TAG }}
target: builder

- name: Test
run: |
docker run --rm ${{ env.BUILDER_IMAGE }}:${{ env.TAG }} json
- name: Build release image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: false
tags: ${{ env.BUILDER_IMAGE }}:${{ env.TAG }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.html
*.json
*.pdf
build
build/*
.idea
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 21.12b0
hooks:
- id: black
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# v1.1.0

Added:
- Automated with Taskfile

Fixed:
- yq setup instructions

# v1.0.0

Added:
- skill additional metadata support
- build automation

# v0.1.0

Added:
- CV Yaml in yaml-cv structure
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM ubuntu:22.04 as builder

WORKDIR /app

ARG VERSION=v4.9.6
ARG BINARY=yq_linux_386
ARG TASK_VERSION=v3.17.0
ARG TASK_BINARY=task_linux_amd64.tar.gz

RUN apt-get update && apt-get install -y \
npm \
wget \
wkhtmltopdf \
libfontconfig1 \
libxtst6 \
rubygems \
&& rm -rf /var/lib/apt/lists/*

ARG VERSION=v4.9.6
ARG BINARY=yq_linux_386
RUN wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY} -O /usr/bin/yq \
&& chmod +x /usr/bin/yq

RUN wget -O- https://github.com/go-task/task/releases/download/${TASK_VERSION}/${TASK_BINARY} \
| tar xz -C /usr/bin


COPY src/ src/
COPY scripts/ scripts/
COPY Taskfile.yaml Taskfile.yaml
COPY .env .env

ENTRYPOINT ["/usr/bin/task"]

FROM builder as build
RUN task build

FROM busybox as release
WORKDIR /app
COPY --from=build /app/build/cv.html cv.html
VOLUME /app
48 changes: 48 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
pipeline {

agent {
node {
label 'docker'
}
}

parameters {
string(name: 'IMAGE_TAG', defaultValue: "", description: '')
}

environment {
TAG = "${params.IMAGE_TAG != "" ? "${params.IMAGE_TAG}" : "${GIT_COMMIT}"}"
}

stages {

stage("Begin") {
steps {
checkout scm
}
}

stage('Builder image and test') {
steps {
script {

builderImage = docker.build("cv-builder:${TAG}")
builderImage.withRun {c ->
"json"
}
}
}
}

stage('Release image') {
steps {
script {
docker.build("cv:${TAG}")
}
}
}


}

}
55 changes: 55 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: '3'

dotenv: ['.env']

env:
IMAGE_TAG: '{{ .IMAGE_TAG | default "test" }}'
PROJECT: '{{ .PROJECT | default "cv" }}'

tasks:
build:
cmds:
- scripts/build.sh

json:
deps:
- build
cmds:
- yq '. | to_json' {{ .BUILD_PATH }}/{{ .CV }}.yaml > {{ .BUILD_PATH }}/{{ .CV }}.json

skill_by_level:
env:
LEVEL: ".LEVEL"
cmds:
- yq '.skills[] | select(.level == "{{ .LEVEL }}") | .name' {{ .SRC_PATH }}/skills.yaml


docker-builder:
cmds:
- docker build -t cv-builder:{{ .IMAGE_TAG }} --target builder .

docker-release:
docker build -t cv:{{ .IMAGE_TAG }} .

docker-build:
cmds:
- task: docker-builder
- task: docker-release

docker-run-task:
deps:
- docker-builder
cmds:
- docker run --rm -ti cv-builder:{{ .IMAGE_TAG }} {{.CLI_ARGS}}

docker-server-foreground:
docker-compose -p {{ .PROJECT }} up

docker-server-background:
docker-compose -p {{ .PROJECT }} up -d

docker-server-stop:
docker-compose -p {{ .PROJECT }} down -v --remove-orphans

test-ha-server:
while true; do curl -v http://localhost:8080 & sleep 1; done;
8 changes: 8 additions & 0 deletions config/nginx/balancer.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
server {
listen 80;
resolver 127.0.0.11 ipv6=off valid=10s;
set $backend "http://worker";
location / {
proxy_pass $backend;
}
}
8 changes: 8 additions & 0 deletions config/nginx/worker.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
server {
listen 80;

location / {
root /usr/share/nginx/html;
index cv.html;
}
}
31 changes: 31 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
services:
cv:
build:
context: .
dockerfile: Dockerfile.ubuntu
target: release
volumes:
- cv:/app

worker:
depends_on:
- cv
image: nginx:1.23.2-alpine
deploy:
replicas: 3
volumes:
- ./config/nginx/worker.conf:/etc/nginx/conf.d/default.conf
- cv:/usr/share/nginx/html
- cv:/app

balancer:
depends_on:
- worker
ports:
- 8080:80
image: nginx:1.23.2-alpine
volumes:
- ./config/nginx/balancer.conf:/etc/nginx/conf.d/default.conf

volumes:
cv:
23 changes: 23 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -e

SCRIPT_DIR=$(readlink -f $(dirname $BASH_SOURCE))
ROOT_DIR=$(readlink -f "$SCRIPT_DIR/..")
BUILD_PATH="$ROOT_DIR/$BUILD_PATH"

source $ROOT_DIR/.env

echo "Building yamlcv"
$SCRIPT_DIR/generate_cv.sh

CV_YAML="$BUILD_PATH/$CV.yaml"
CV_HTML="$BUILD_PATH/$CV.html"
CV_PDF="$BUILD_PATH/$CV.pdf"

echo "Building HTML from $CV_YAML"
yaml-cv yaml-cv $CV_YAML > $BUILD_PATH/${CV}.html

echo "Building PDF from $CV"
yaml-cv yaml-cv $CV_YAML --pdf $BUILD_PATH/${CV}.pdf

echo "Check files in ./$BUILD_PATH directory"
32 changes: 32 additions & 0 deletions scripts/generate_cv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -e

SCRIPT_DIR=$(readlink -f $(dirname $BASH_SOURCE))
ROOT_DIR=$(readlink -f "$SCRIPT_DIR/..")

source $ROOT_DIR/.env
SRC_PATH="$ROOT_DIR/$SRC_PATH"
BUILD_PATH="$ROOT_DIR/$BUILD_PATH"

mkdir -p $BUILD_PATH

SKILLS="$SRC_PATH/skills.yaml"
YAMLCV="$SRC_PATH/yamlcv.yaml"
CV_YAML="$BUILD_PATH/${CV}.yaml"

echo 'cleanup'
rm -vf $BUILD_PATH/* 2>/dev/null
echo 'copy template'
cp -v $YAMLCV $CV_YAML

IFS=$'\n'
CATEGORIES=$(yq '.. comments="" | explode(.) | .categories[]' $SKILLS)

for CATEGORY in $CATEGORIES; do
export CATEGORY
export ITEMS=$(yq '.. comments="" | explode(.) | .skills[] | select(.category == env(CATEGORY)) | .name as $item ireduce ([]; . + $item) | join(",") ' $SKILLS | uniq)
echo "updating '$CATEGORY' items in $CV_YAML"
yq -i '.technical += {"category": env(CATEGORY), "items": env(ITEMS)}' $CV_YAML
done

echo "Successfully built $CV_YAML"
Loading