Compare commits
8 Commits
lab5-hiatu
...
master
Author | SHA1 | Date | |
---|---|---|---|
b52025e597 | |||
ca6c79428c | |||
01ef30678d | |||
03f0b75d63 | |||
0374b173c8 | |||
d4b830096f | |||
8ca9a1c385 | |||
cbe236f220 |
100
.gitea/workflows/prod.yaml
Normal file
100
.gitea/workflows/prod.yaml
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
name: build-and-deploy-prod
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-cc:
|
||||||
|
runs-on: docker
|
||||||
|
services:
|
||||||
|
docker:
|
||||||
|
image: docker:dind
|
||||||
|
options: --privileged --shm-size=2g
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
|
steps:
|
||||||
|
- name: Clone repo
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
git init
|
||||||
|
git remote add gitea http://10.1.1.1:3000/hasslesstech/devops-lab4
|
||||||
|
git fetch gitea
|
||||||
|
git checkout gitea/master
|
||||||
|
- name: Build container
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
docker build . -f Dockerfile-cc -t 10.5.1.10:5000/prod/cc
|
||||||
|
- name: Push container
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
docker push 10.5.1.10:5000/prod/cc
|
||||||
|
|
||||||
|
build-hm:
|
||||||
|
runs-on: docker
|
||||||
|
services:
|
||||||
|
docker:
|
||||||
|
image: docker:dind
|
||||||
|
options: --privileged --shm-size=2g
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
|
steps:
|
||||||
|
- name: Clone repo
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
git init
|
||||||
|
git remote add gitea http://10.1.1.1:3000/hasslesstech/devops-lab4
|
||||||
|
git fetch gitea
|
||||||
|
git checkout gitea/master
|
||||||
|
- name: Build container
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
docker build . -f Dockerfile-hm -t 10.5.1.10:5000/prod/hm
|
||||||
|
- name: Push container
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
docker push 10.5.1.10:5000/prod/hm
|
||||||
|
|
||||||
|
build-map:
|
||||||
|
runs-on: docker
|
||||||
|
services:
|
||||||
|
docker:
|
||||||
|
image: docker:dind
|
||||||
|
options: --privileged --shm-size=2g
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
|
steps:
|
||||||
|
- name: Clone repo
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
git init
|
||||||
|
git remote add gitea http://10.1.1.1:3000/hasslesstech/devops-lab4
|
||||||
|
git fetch gitea
|
||||||
|
git checkout gitea/master
|
||||||
|
- name: Build container
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
docker build . -f Dockerfile-map -t 10.5.1.10:5000/prod/map
|
||||||
|
- name: Push container
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
docker push 10.5.1.10:5000/prod/map
|
||||||
|
|
||||||
|
deploy-all:
|
||||||
|
runs-on: hardware-x86_64
|
||||||
|
needs:
|
||||||
|
- build-cc
|
||||||
|
- build-hm
|
||||||
|
- build-map
|
||||||
|
steps:
|
||||||
|
- run: |
|
||||||
|
ssh -i ~/prod-key root@10.5.1.11 "sh -c 'rm -rf devops-lab4 ; git clone http://10.1.1.1:3000/hasslesstech/devops-lab4 && cd devops-lab4 &&
|
||||||
|
docker-compose -f docker-compose-prod.yaml up -d'"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
72
Dockerfile
Normal file
72
Dockerfile
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
# dotnet build environment
|
||||||
|
FROM alpine:latest as dotnet
|
||||||
|
WORKDIR /
|
||||||
|
|
||||||
|
RUN apk add dotnet8-sdk git
|
||||||
|
RUN git clone https://gitlab.com/kzotkin/hiveemulator
|
||||||
|
|
||||||
|
WORKDIR /hiveemulator/src/CommunicationControl/
|
||||||
|
RUN dotnet build DevOpsProject/DevOpsProject.CommunicationControl.API.csproj
|
||||||
|
RUN dotnet build DevOpsProject.HiveMind.API/DevOpsProject.HiveMind.API.csproj
|
||||||
|
|
||||||
|
|
||||||
|
# nodejs build environment
|
||||||
|
#FROM alpine:latest as nodejs
|
||||||
|
#WORKDIR /
|
||||||
|
|
||||||
|
#RUN apk add git npm
|
||||||
|
#RUN git clone https://gitlab.com/kzotkin/hiveemulator
|
||||||
|
|
||||||
|
#WORKDIR /hiveemulator/src/MapClient/
|
||||||
|
#RUN npm install
|
||||||
|
#RUN npm run build
|
||||||
|
|
||||||
|
|
||||||
|
# production environment
|
||||||
|
FROM alpine:latest
|
||||||
|
WORKDIR /
|
||||||
|
|
||||||
|
#RUN apk add dotnet8-sdk redis openrc lighttpd npm
|
||||||
|
#RUN apk add git dotnet8-sdk redis openrc npm
|
||||||
|
#RUN apk add git aspnetcore8-runtime redis openrc npm
|
||||||
|
RUN apk add aspnetcore8-runtime redis openrc npm
|
||||||
|
|
||||||
|
#RUN git clone https://gitlab.com/kzotkin/hiveemulator
|
||||||
|
#COPY --from=nodejs /hiveemulator/ /hiveemulator/
|
||||||
|
COPY --from=dotnet /hiveemulator/ /hiveemulator/
|
||||||
|
#COPY --from=nodejs /hiveemulator/src/MapClient/dist/* /var/www/localhost/htdocs/
|
||||||
|
|
||||||
|
#RUN mkdir /hive-cc
|
||||||
|
#COPY --from=0 /hiveemulator/src/CommunicationControl/DevOpsProject/* /hive-cc/
|
||||||
|
#COPY --from=dotnet /hiveemulator/src/CommunicationControl/DevOpsProject/* /hiveemulator/src/CommunicationControl/DevOpsProject/
|
||||||
|
#COPY --from=dotnet /hiveemulator/src/CommunicationControl/DevOpsProject.HiveMind.API/* /hiveemulator/src/CommunicationControl/DevOpsProject.HiveMind.API/
|
||||||
|
|
||||||
|
#RUN mkdir /hive-hm
|
||||||
|
#COPY --from=0 /hiveemulator/src/CommunicationControl/DevOpsProject.HiveMind.API/* /hive-hm/
|
||||||
|
|
||||||
|
WORKDIR /hiveemulator/src/MapClient/
|
||||||
|
RUN npm install
|
||||||
|
RUN sed -i 's/localhost/10\.1\.1\.2/' public/config.json
|
||||||
|
|
||||||
|
WORKDIR /
|
||||||
|
COPY ./daemon-files/hive-cc /etc/init.d/hive-cc
|
||||||
|
COPY ./daemon-files/hive-hm /etc/init.d/hive-hm
|
||||||
|
COPY ./daemon-files/hive-map /etc/init.d/hive-map
|
||||||
|
RUN chmod u+x /etc/init.d/hive-hm /etc/init.d/hive-cc /etc/init.d/hive-map
|
||||||
|
|
||||||
|
#RUN mkdir /etc/rulevels/{stage-redis,stage-cc,stage-hm,stage-map}
|
||||||
|
|
||||||
|
#RUN rc-update add redis default
|
||||||
|
#RUN rc-update add hive-hm default
|
||||||
|
#RUN rc-update add hive-cc default
|
||||||
|
#RUN rc-update add hive-map default
|
||||||
|
|
||||||
|
CMD sh -c "openrc default ; \
|
||||||
|
rc-service redis start ; \
|
||||||
|
rc-service hive-cc start ; \
|
||||||
|
rc-service hive-hm start ; \
|
||||||
|
rc-service hive-map start ; \
|
||||||
|
exec sh"
|
||||||
|
|
||||||
|
|
||||||
|
|
24
Dockerfile-cc
Normal file
24
Dockerfile-cc
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# dotnet build environment
|
||||||
|
FROM alpine:latest as dotnet
|
||||||
|
WORKDIR /
|
||||||
|
|
||||||
|
RUN apk add git
|
||||||
|
RUN git clone https://gitlab.com/kzotkin/hiveemulator
|
||||||
|
|
||||||
|
RUN apk add dotnet8-sdk
|
||||||
|
|
||||||
|
WORKDIR /hiveemulator/src/CommunicationControl/
|
||||||
|
RUN dotnet publish DevOpsProject/DevOpsProject.CommunicationControl.API.csproj
|
||||||
|
|
||||||
|
# production environment
|
||||||
|
#FROM mcr.microsoft.com/dotnet/aspnet:8.0 as prod
|
||||||
|
FROM alpine:latest as prod
|
||||||
|
#COPY --from=dotnet /hiveemulator/src/CommunicationControl/DevOpsProject/bin/Release/net8.0/ /app/
|
||||||
|
RUN apk add aspnetcore8-runtime
|
||||||
|
RUN mkdir -p /hiveemulator/src/CommunicationControl/DevOpsProject/bin/Release/net8.0/
|
||||||
|
COPY --from=dotnet /hiveemulator/src/CommunicationControl/DevOpsProject/bin/Release/net8.0/ /hiveemulator/src/CommunicationControl/DevOpsProject/bin/Release/net8.0/
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
WORKDIR /hiveemulator/src/CommunicationControl/DevOpsProject/bin/Release/net8.0/
|
||||||
|
ENTRYPOINT ["./DevOpsProject.CommunicationControl.API"]
|
23
Dockerfile-hm
Normal file
23
Dockerfile-hm
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# dotnet build environment
|
||||||
|
FROM alpine:latest as dotnet
|
||||||
|
WORKDIR /
|
||||||
|
|
||||||
|
RUN apk add git
|
||||||
|
RUN git clone https://gitlab.com/kzotkin/hiveemulator
|
||||||
|
|
||||||
|
RUN apk add dotnet8-sdk
|
||||||
|
|
||||||
|
WORKDIR /hiveemulator/src/CommunicationControl/
|
||||||
|
RUN dotnet publish DevOpsProject.HiveMind.API/DevOpsProject.HiveMind.API.csproj
|
||||||
|
|
||||||
|
|
||||||
|
# production environment
|
||||||
|
#FROM mcr.microsoft.com/dotnet/aspnet:8.0 as prod
|
||||||
|
FROM alpine:latest as prod
|
||||||
|
RUN apk add aspnetcore8-runtime
|
||||||
|
RUN mkdir -p /hiveemulator/src/CommunicationControl/DevOpsProject.HiveMind.API/bin/Release/net8.0/
|
||||||
|
#COPY --from=dotnet /hiveemulator/src/CommunicationControl/DevOpsProject.HiveMind.API/bin/Release/net8.0/ /app/
|
||||||
|
COPY --from=dotnet /hiveemulator/src/CommunicationControl/DevOpsProject.HiveMind.API/bin/Release/net8.0/ /hiveemulator/src/CommunicationControl/DevOpsProject.HiveMind.API/bin/Release/net8.0/
|
||||||
|
|
||||||
|
WORKDIR /hiveemulator/src/CommunicationControl/DevOpsProject.HiveMind.API/bin/Release/net8.0/
|
||||||
|
ENTRYPOINT ["./DevOpsProject.HiveMind.API"]
|
22
Dockerfile-map
Normal file
22
Dockerfile-map
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# nodejs build environment
|
||||||
|
FROM alpine:latest as nodejs
|
||||||
|
WORKDIR /
|
||||||
|
|
||||||
|
RUN apk add git
|
||||||
|
RUN git clone https://gitlab.com/kzotkin/hiveemulator
|
||||||
|
|
||||||
|
RUN apk add npm
|
||||||
|
|
||||||
|
WORKDIR /hiveemulator/src/MapClient/
|
||||||
|
RUN npm install
|
||||||
|
RUN npm run build
|
||||||
|
RUN rm public/config.json
|
||||||
|
|
||||||
|
|
||||||
|
# production environment
|
||||||
|
FROM nginx:alpine
|
||||||
|
COPY --from=nodejs /hiveemulator/src/MapClient/dist/ /usr/share/nginx/html/
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
ENTRYPOINT ["nginx", "-g", "daemon off;"]
|
14
daemon-files/hive-cc
Normal file
14
daemon-files/hive-cc
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/sbin/openrc-run
|
||||||
|
|
||||||
|
command="./DevOpsProject.CommunicationControl.API"
|
||||||
|
command_args=""
|
||||||
|
pidfile="/run/hive-cc.pid"
|
||||||
|
supervisor="supervise-daemon"
|
||||||
|
|
||||||
|
start_pre() {
|
||||||
|
cd /hiveemulator/src/CommunicationControl/DevOpsProject/bin/Debug/net8.0/
|
||||||
|
}
|
||||||
|
|
||||||
|
depend() {
|
||||||
|
need redis
|
||||||
|
}
|
14
daemon-files/hive-hm
Normal file
14
daemon-files/hive-hm
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/sbin/openrc-run
|
||||||
|
|
||||||
|
command="./DevOpsProject.HiveMind.API"
|
||||||
|
command_args=""
|
||||||
|
pidfile="/run/hive-hm.pid"
|
||||||
|
supervisor="supervise-daemon"
|
||||||
|
|
||||||
|
start_pre() {
|
||||||
|
cd /hiveemulator/src/CommunicationControl/DevOpsProject.HiveMind.API/bin/Debug/net8.0/
|
||||||
|
}
|
||||||
|
|
||||||
|
depend() {
|
||||||
|
need hive-cc
|
||||||
|
}
|
14
daemon-files/hive-map
Normal file
14
daemon-files/hive-map
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/sbin/openrc-run
|
||||||
|
|
||||||
|
command="npm"
|
||||||
|
command_args="run dev"
|
||||||
|
pidfile="/run/hive-map.pid"
|
||||||
|
supervisor="supervise-daemon"
|
||||||
|
|
||||||
|
depend() {
|
||||||
|
need hive-cc
|
||||||
|
}
|
||||||
|
|
||||||
|
start_pre() {
|
||||||
|
cd /hiveemulator/src/MapClient/
|
||||||
|
}
|
39
docker-compose-dev.yaml
Normal file
39
docker-compose-dev.yaml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
services:
|
||||||
|
redis:
|
||||||
|
image: redis:7
|
||||||
|
restart: always
|
||||||
|
networks:
|
||||||
|
- sys
|
||||||
|
|
||||||
|
cc:
|
||||||
|
image: 10.5.1.10:5000/dev/cc
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
Redis__ConnectionString: "redis:6379"
|
||||||
|
ports:
|
||||||
|
- 8080:8080
|
||||||
|
networks:
|
||||||
|
- sys
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
|
||||||
|
hm:
|
||||||
|
image: 10.5.1.10:5000/dev/hm
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
CommunicationConfiguration__CommunicationControlIP: "cc"
|
||||||
|
networks:
|
||||||
|
- sys
|
||||||
|
depends_on:
|
||||||
|
- cc
|
||||||
|
|
||||||
|
map:
|
||||||
|
image: 10.5.1.10:5000/dev/map
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- ./map/config-dev.json:/usr/share/nginx/html/config.json:ro
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
|
||||||
|
networks:
|
||||||
|
sys:
|
39
docker-compose-prod.yaml
Normal file
39
docker-compose-prod.yaml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
services:
|
||||||
|
redis:
|
||||||
|
image: redis:7
|
||||||
|
restart: always
|
||||||
|
networks:
|
||||||
|
- sys
|
||||||
|
|
||||||
|
cc:
|
||||||
|
image: 10.5.1.10:5000/prod/cc
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
Redis__ConnectionString: "redis:6379"
|
||||||
|
ports:
|
||||||
|
- 8080:8080
|
||||||
|
networks:
|
||||||
|
- sys
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
|
||||||
|
hm:
|
||||||
|
image: 10.5.1.10:5000/prod/hm
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
CommunicationConfiguration__CommunicationControlIP: "cc"
|
||||||
|
networks:
|
||||||
|
- sys
|
||||||
|
depends_on:
|
||||||
|
- cc
|
||||||
|
|
||||||
|
map:
|
||||||
|
image: 10.5.1.10:5000/prod/map
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- ./map/config-prod.json:/usr/share/nginx/html/config.json:ro
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
|
||||||
|
networks:
|
||||||
|
sys:
|
3
map/config-dev.json
Normal file
3
map/config-dev.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"API": "http://10.5.1.12:8080/api/v1/client"
|
||||||
|
}
|
3
map/config-prod.json
Normal file
3
map/config-prod.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"API": "http://10.5.1.11:8080/api/v1/client"
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user