master
pipistrello 2022-02-12 17:53:47 +03:00
parent 88168e59c7
commit 04bf213e9b
5 changed files with 127 additions and 0 deletions

61
Dockerfile Normal file
View File

@ -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"]

26
README.md Normal file
View File

@ -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
```

21
init.sh Normal file
View File

@ -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

13
restart.sh Normal file
View File

@ -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

6
run.sh Normal file
View File

@ -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;