From 04bf213e9bde9aa35da7b16ca36304f265bc9784 Mon Sep 17 00:00:00 2001 From: pipistrello Date: Sat, 12 Feb 2022 17:53:47 +0300 Subject: [PATCH] first --- Dockerfile | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 26 +++++++++++++++++++++++ init.sh | 21 +++++++++++++++++++ restart.sh | 13 ++++++++++++ run.sh | 6 ++++++ 5 files changed, 127 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 init.sh create mode 100644 restart.sh create mode 100644 run.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f914298 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,61 @@ +# Сервер взаимодействия 1С 8.3 +#https://its.1c.ru/db/v8311doc/content/232/hdoc + + +FROM debian:bullseye-slim + + + +RUN mkdir -p /usr/share/man/man1 && \ + apt-get update && apt-get install -y \ + wget curl sudo gawk + +RUN mkdir -p /opt/dist && cd /opt/dist \ + && wget https://download.bell-sw.com/java/11.0.14+9/bellsoft-jdk11.0.14+9-linux-amd64.deb \ + && wget http://casa.ru/collaborationserver1c/1c_cs_11.0.25_linux_x86_64.tar.gz --no-check-certificate + +RUN cd /opt/dist \ + && tar xzf 1c_cs_11.0.25_linux_x86_64.tar.gz \ + && dpkg -i bellsoft-jdk11.0.14+9-linux-amd64.deb; apt-get -f install -y \ + && dpkg -i *.deb \ + && ls /opt/dist \ + && ./1ce-installer-cli install \ + && rm -rf * + + +RUN apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +ENV JAVA_HOME /usr/lib/jvm/bellsoft-java11-amd64 +ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-8-openjdk-amd64/bin:/opt/1C/1CE/components/1c-enterprise-ring-0.19.5+12-x86_64/ + + +RUN mkdir -p /var/cs/cs_instance && \ + mkdir -p /var/cs/hc_instance && \ + mkdir -p /var/cs/elastic_instance \ + && chmod +x /opt/1C/1CE/components/1c-enterprise-ring-0.19.5+12-x86_64/ring + +RUN ring cs instance create --dir /var/cs/cs_instance --owner root \ + && ring hazelcast instance create --dir /var/cs/hc_instance --owner root \ + && ring elasticsearch instance create --dir /var/cs/elastic_instance --owner root + +#Сервис сыпется на pidof это такой дурацкйи костыль +RUN mv /bin/pidof /bin/_pidof && cp /bin/echo /bin/pidof + +RUN ring hazelcast --instance hc_instance service create --username root --stopped --java-home $JAVA_HOME +RUN ring elasticsearch --instance elastic_instance service create --username root --stopped --java-home $JAVA_HOME +RUN ring cs --instance cs_instance service create --username root --stopped --java-home $JAVA_HOME + +#RUN mv /bin/_pidof /bin/pidof + +COPY run.sh / +COPY init.sh / +COPY restart.sh / +RUN chmod +x /*.sh + +ENV POSTGRES_URL "postgres:5432/cs" +ENV POSTGRES_USER "postgres" +ENV POSTGRES_PASSWORD "postgres" + +EXPOSE 8181 +CMD ["/run.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..e0e47eb --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# 1С: Сервер взаимодействия docker + + +## Запуск + +### Запустить контейнер с посгрес +``` +docker run -d --name postgres -e POSTGRES_PASSWORD=myPassword -d postgres +``` +### Создать базу +``` +docker exec -ti --user postgres postgres psql + +Вводим +CREATE DATABASE cs OWNER postgres; +\c cs +CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; +``` + +### Запустить сервер взаимодействия + +``` +docker run -ti --name 1ccommunicationserver --link postgres:postgres -e POSTGRES_URL=postgress:5432/cs -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=myPassword -p 8181:8181 asdaru/collaboration_server_1c +``` + + diff --git a/init.sh b/init.sh new file mode 100644 index 0000000..0e2db72 --- /dev/null +++ b/init.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +ring cs --instance cs_instance jdbc pools --name common set-params --url jdbc:postgresql://$POSTGRES_URL?currentSchema=public +ring cs --instance cs_instance jdbc pools --name common set-params --username $POSTGRES_USER +ring cs --instance cs_instance jdbc pools --name common set-params --password $POSTGRES_PASSWORD +ring cs --instance cs_instance jdbc pools --name privileged set-params --url jdbc:postgresql://$POSTGRES_URL?currentSchema=public +ring cs --instance cs_instance jdbc pools --name privileged set-params --username $POSTGRES_USER +ring cs --instance cs_instance jdbc pools --name privileged set-params --password $POSTGRES_PASSWORD + + +ring cs --instance cs_instance websocket set-params --hostname 0.0.0.0 +ring cs --instance cs_instance websocket set-params --port 8181 + +ring hazelcast --instance hc_instance service start +ring elasticsearch --instance elastic_instance service start +ring cs --instance cs_instance service start + +sleep 30 + +curl -Sf -X POST -H "Content-Type: application/json" \ +-d "{ \"url\" : \"jdbc:postgresql://$POSTGRES_URL\", \"username\" : \"$POSTGRES_USER\", \"password\" : \"$POSTGRES_PASSWORD\", \"enabled\" : true }" -u admin:admin http://localhost:8087/admin/bucket_server \ No newline at end of file diff --git a/restart.sh b/restart.sh new file mode 100644 index 0000000..effdb1a --- /dev/null +++ b/restart.sh @@ -0,0 +1,13 @@ +#!/bin/bash +sleep 10 +ring hazelcast --instance hc_instance service stop +ring elasticsearch --instance elastic_instance service stop +ring cs --instance cs_instance service stop + +sleep 15 + +ring hazelcast --instance hc_instance service start +sleep 1 +ring elasticsearch --instance elastic_instance service start +sleep 1 +ring cs --instance cs_instance service start diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..a389a2b --- /dev/null +++ b/run.sh @@ -0,0 +1,6 @@ +#!/bin/bash +#======== RUN and DELETE INIT CODE == +/init.sh && sed -i "s/^\/init.sh.*/\/restart.sh/" /run.sh + +echo "start ok" +while true; do sleep 600; done; \ No newline at end of file