docker file and ansible playbook addition

This commit is contained in:
Expand-sys 2022-11-21 15:31:54 +11:00
parent 89448a4b12
commit decfd83931
5 changed files with 112 additions and 6 deletions

3
.gitignore vendored
View file

@ -1,3 +1,4 @@
.vscode
build
ccash_config.hpp
ccash_config.hpp
deployment/.yamllint

View file

@ -1,18 +1,21 @@
FROM alpine:3.11
FROM alpine:latest
WORKDIR /
RUN apk update && apk add git cmake g++ make protobuf jsoncpp-dev openssl libressl-dev zlib-dev util-linux-dev libtool autoconf automake python3
RUN apk update && apk add bash git cmake g++ make protobuf jsoncpp-dev openssl libressl-dev zlib-dev util-linux-dev libtool autoconf automake python3
RUN git clone --recurse-submodules https://github.com/EntireTwix/CCash.git
WORKDIR /CCash/third_party/base64/
RUN AVX2_CFLAGS=-mavx2 SSSE3_CFLAGS=-mssse3 SSE41_CFLAGS=-msse4.1 SSE42_CFLAGS=-msse4.2 AVX_CFLAGS=-mavx make lib/libbase64.o
RUN mkdir /CCash/build
WORKDIR /CCash/build
RUN cmake -DDROGON_CONFIG_LOC=/CCash/config/config.json -DUSER_SAVE_LOC=/CCash/config/users.dat ..
RUN cmake -DDROGON_CONFIG_LOC="/CCash/config/config.json" -DUSER_SAVE_LOC="/CCash/config/users.dat" ..
RUN make -j$(nproc)
ARG ADMIN_A=admin
ARG SAVE_FREQ=2
CMD ["sh", "-c", "/CCash/config/ssl.sh && /CCash/build/bank ${ADMIN_A} ${SAVE_FREQ}"]
WORKDIR /
RUN sed -i 's/\r$//' /CCash/config/ssl.sh && \
chmod +x /CCash/config/ssl.sh
RUN /CCash/build/bank
CMD /CCash/config/ssl.sh && /CCash/build/bank ${ADMIN_A} ${SAVE_FREQ}

2
deployment/inventory Normal file
View file

@ -0,0 +1,2 @@
[all]
10.10.0.145 ansible_ssh_user=root ansible_ssh_common_args='-o StrictHostKeyChecking=no'

96
deployment/main.yml Normal file
View file

@ -0,0 +1,96 @@
---
- hosts: all
vars:
become: true
pre_tasks:
- name: load variables
ansible.builtin.include_vars: '{{ item }}'
with_first_found:
- "default.yml"
tasks:
- name: refresh packages update
yum:
name: "*"
update_cache: true
state: latest
- name: Add repository
yum:
name: epel-release
state: latest
when: ansible_os_family == "RedHat"
- name: install dependencies
yum:
name: [git, gcc, gcc-c++, libuuid-devel, openssl-devel, zlib-devel, jsoncpp-devel, cmake]
state: present
when: ansible_os_family == "RedHat"
- name: clone CCash repository
git:
repo: https://github.com/EntireTwix/CCash.git
dest: '{{BUILD_DIR}}/CCash'
recursive: true
update: false
- name: Make lib base64
community.general.make:
chdir: '{{BUILD_DIR}}/CCash/third_party/base64'
params:
AVX2_CFLAGS: -mavx2
SSSE3_CFLAGS: -mssse3
SSE41_CFLAGS: -msse4.1
SSE42_CFLAGS: -msse4.2
AVX_CFLAGS: -mavx
- name: create build dir
file:
path: '{{BUILD_DIR}}/CCash/build'
state: directory
- name: Cmake CCash
ansible.builtin.command:
chdir: '{{BUILD_DIR}}/CCash/build'
cmd: |
cmake -DDROGON_CONFIG_LOC="{{ BUILD_DIR }}/CCash/config/config.json" -DUSER_SAVE_LOC="{{ BUILD_DIR }}/CCash/config/users.dat" ..
- name: make CCash
community.general.make:
chdir: '{{BUILD_DIR}}/CCash/build'
params:
NUM_THREADS: '-j{{ ansible_processor_vcpus }}'
- name: create users file
ansible.builtin.command:
chdir: '{{BUILD_DIR}}/CCash/build/'
cmd: ./bank
creates: '{{ BUILD_DIR }}/CCash/config/users.dat'
- name: chmod +x ssl.sh
ansible.builtin.file:
mode: u+x
path: '{{BUILD_DIR}}/CCash/config/ssl.sh'
- name: generate default ssl
ansible.builtin.command:
chdir: '{{BUILD_DIR}}/CCash/config/'
cmd: './ssl.sh'
- name: create service file
ansible.builtin.copy:
content: |
[Unit]
Description=CCash API Server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=simple
ExecStart={{BUILD_DIR}}/CCash/build/bank {{ADMIN_A}} {{SAVE_FREQ}}
ExecStop=/bin/kill -WINCH ${MAINPID}
KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target
dest: /etc/systemd/system/ccash.service

View file

@ -0,0 +1,4 @@
---
BUILD_DIR: '/root'
ADMIN_A: "admin"
SAVE_FREQ: "2"