added ci/cd
This commit is contained in:
parent
b8bbfff381
commit
e24b0f3660
2
.dockerignore
Normal file
2
.dockerignore
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
.git
|
||||||
|
.dockerignore
|
53
.gitlab-ci.yml
Normal file
53
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
stages:
|
||||||
|
- build
|
||||||
|
- deploy
|
||||||
|
|
||||||
|
variables:
|
||||||
|
PY_COLORS: '1'
|
||||||
|
ANSIBLE_FORCE_COLOR: '1'
|
||||||
|
ANSIBLE_PYTHON_INTERPRETER: auto_silent
|
||||||
|
ANSIBLE_STDOUT_CALLBACK: debug
|
||||||
|
|
||||||
|
docker-build-master:
|
||||||
|
# Official docker image.
|
||||||
|
image: docker:latest
|
||||||
|
stage: build
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
services:
|
||||||
|
- docker:dind
|
||||||
|
before_script:
|
||||||
|
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||||
|
script:
|
||||||
|
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
|
||||||
|
- docker push "$CI_REGISTRY_IMAGE"
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
|
||||||
|
docker-build:
|
||||||
|
# Official docker image.
|
||||||
|
image: docker:latest
|
||||||
|
stage: build
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
services:
|
||||||
|
- docker:dind
|
||||||
|
before_script:
|
||||||
|
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||||
|
script:
|
||||||
|
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
|
||||||
|
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
|
||||||
|
except:
|
||||||
|
- main
|
||||||
|
|
||||||
|
deploy-master:
|
||||||
|
#when: manual
|
||||||
|
stage: deploy
|
||||||
|
image:
|
||||||
|
name: cytopia/ansible:latest-tools
|
||||||
|
entrypoint: [""]
|
||||||
|
script:
|
||||||
|
- chmod 600 "${ANSIBLE_SSH_KEY_PRIVATE}"
|
||||||
|
- ansible-playbook -i ./deployment/hosts.yml --private-key "${ANSIBLE_SSH_KEY_PRIVATE}" "./deployment/deployment.yml"
|
||||||
|
only:
|
||||||
|
- main
|
12
Dockerfile
Normal file
12
Dockerfile
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
FROM node:lts-alpine as build-stage
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# production stage
|
||||||
|
FROM nginx:stable-alpine as production-stage
|
||||||
|
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
22
deployment/deployment.yml
Normal file
22
deployment/deployment.yml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
---
|
||||||
|
- hosts: snickers-docker
|
||||||
|
gather_facts: no
|
||||||
|
vars:
|
||||||
|
verbose: false
|
||||||
|
compose_folder: "/mnt/docker-storage/radiator-web/"
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Ensures {{ compose_folder }} dir exists
|
||||||
|
stat:
|
||||||
|
path: "{{ compose_folder }}docker-compose.yml"
|
||||||
|
register: file_details
|
||||||
|
|
||||||
|
- name: Fail if docker-compose file doesn't exist
|
||||||
|
fail:
|
||||||
|
msg: "docker-compose.yml doesn't exist in expected location (expected in {{ compose_folder }})"
|
||||||
|
when: not file_details.stat.exists
|
||||||
|
|
||||||
|
- name: Update container image
|
||||||
|
community.general.docker_compose:
|
||||||
|
project_src: "{{ compose_folder }}"
|
||||||
|
pull: yes
|
10
deployment/hosts.yml
Normal file
10
deployment/hosts.yml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
all:
|
||||||
|
vars:
|
||||||
|
ansible_python_interpreter: /usr/bin/python3
|
||||||
|
hosts:
|
||||||
|
snickers-docker:
|
||||||
|
ansible_host: 192.168.200.11
|
||||||
|
ansible_port: 22
|
||||||
|
ansible_user: root
|
||||||
|
ansible_ssh_extra_args: '-o StrictHostKeyChecking=no'
|
||||||
|
ansible_ssh_common_args: '-o ProxyCommand="ssh -o StrictHostKeyChecking=no -i "${ANSIBLE_SSH_KEY_PRIVATE}" -W %h:%p root@vserver8.alex-detsch.de -p 52"'
|
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
web:
|
||||||
|
image: registry.alex-detsch.de/fem/radiator/radiator-web
|
||||||
|
restart: always
|
||||||
|
healthcheck:
|
||||||
|
test: "curl localhost"
|
||||||
|
interval: "60s"
|
||||||
|
timeout: "3s"
|
||||||
|
start_period: "5s"
|
||||||
|
retries: 3
|
||||||
|
stop_grace_period: 3s
|
||||||
|
ports:
|
||||||
|
- "1499:80"
|
Loading…
Reference in a new issue