Dockerfile for Test environment and yaml
This commit is contained in:
parent
8d5a68b49b
commit
5cd1bbcf17
36
.github/workflows/deploy.prod-env.yml
vendored
Normal file
36
.github/workflows/deploy.prod-env.yml
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
name: Build, push and restart docker container on Test environment
|
||||
run-name: ${{ gitea.actor }} is runs ci pipeline
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [ published, edited ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/catthehacker/ubuntu:act-latest
|
||||
steps:
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.wohlleben.dev
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
- name: Restart all Docker Container on Production
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ secrets.STRATO_VPS_HOST_ADDRESS }}
|
||||
username: ${{ secrets.STRATO_VPS_USER_NAME }}
|
||||
key: ${{ secrets.STRATO_VPS_ROOT_USER_SSH_KEY }}
|
||||
script: |
|
||||
docker pull git.wohlleben.dev/itob/rbl-feeder-app:latest
|
||||
docker pull git.wohlleben.dev/itob/rbl-feeder-api:latest
|
||||
docker pull git.wohlleben.dev/itob/rbl-feeder-worker:latest
|
||||
docker pull git.wohlleben.dev/itob/rbl-feeder-monitoring:latest
|
||||
docker stop rbl-feeder-app rbl-feeder-api rbl-feeder-worker rbl-feeder-monitoring
|
||||
docker rm rbl-feeder-app rbl-feeder-api rbl-feeder-worker rbl-feeder-monitoring
|
||||
docker run --init -d --name rbl-feeder-app -p 8000:80 --restart=always git.wohlleben.dev/itob/rbl-feeder-app:latest
|
||||
docker run --init -d --name rbl-feeder-api -p 8001:8080 -e DatabaseName=rblfeeder -e ConnectionUri=${{ secrets.DB_CONNECTION_URI_PROD_ENV }} --restart=always git.wohlleben.dev/itob/rbl-feeder-api:latest
|
||||
docker run --init -d --name rbl-feeder-monitoring -p 8002:8080 -e HostAddress=https://rbl.wohlleben.dev -e DatabaseName=rblfeeder -e ConnectionUri=${{ secrets.DB_CONNECTION_URI_PROD_ENV }} git.wohlleben.dev/itob/rbl-feeder-monitoring:latest
|
||||
docker run --init -d --name rbl-feeder-worker -e HostAddress=https://rblnews.de -e DatabaseName=rblfeeder -e ConnectionUri=${{ secrets.DB_CONNECTION_URI_PROD_ENV }} --restart=always git.wohlleben.dev/itob/rbl-feeder-worker:latest
|
||||
docker system prune -af
|
||||
43
.github/workflows/deploy.test-env.yml
vendored
Normal file
43
.github/workflows/deploy.test-env.yml
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
name: Restart Docker Container on Production
|
||||
run-name: ${{ gitea.actor }} is runs CD pipeline
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [ assigned, opened, synchronize, reopened, edited ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/catthehacker/ubuntu:act-latest
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache
|
||||
IMAGE_NAME: rbl-news-webapp
|
||||
REGISTRY: git.wohlleben.dev
|
||||
REPO_OWNER: itob
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.wohlleben.dev
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
- name: Build and push WebApp container image
|
||||
run: |
|
||||
TODAY=$(date +'%Y-%m-%d')
|
||||
docker build -t ${REGISTRY}/${REPO_OWNER}/${IMAGE_NAME}:${TODAY} -t ${REGISTRY}/${REPO_OWNER}/${IMAGE_NAME}:latest -f IaC/RBLNews.Web/Dockerfile .
|
||||
docker push ${REGISTRY}/${REPO_OWNER}/${IMAGE_NAME}:${TODAY}
|
||||
docker push ${REGISTRY}/${REPO_OWNER}/${IMAGE_NAME}:latest
|
||||
- name: Restart all Docker Container on Test Environment
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ secrets.DOCKER_VM_HOST_ADDRESS }}
|
||||
username: ${{ secrets.DOCKER_VM_HOST_ROOT_USERNAME }}
|
||||
key: ${{ secrets.DOCKER_VM_SSH_USER_ROOT }}
|
||||
script: |
|
||||
docker pull git.wohlleben.dev/itob/rbl-news-webapp:latest
|
||||
docker stop rbl-news-webapp
|
||||
docker rm rbl-news-webapp
|
||||
docker run --init -d --name rbl-news-webapp -p 8000:80 --restart=always git.wohlleben.dev/itob/rbl-news-webapp:latest
|
||||
docker system prune -af
|
||||
25
IaC/.dockerignore
Normal file
25
IaC/.dockerignore
Normal file
@ -0,0 +1,25 @@
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/.project
|
||||
**/.settings
|
||||
**/.toolstarget
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/.idea
|
||||
**/*.*proj.user
|
||||
**/*.dbmdl
|
||||
**/*.jfm
|
||||
**/azds.yaml
|
||||
**/bin
|
||||
**/charts
|
||||
**/docker-compose*
|
||||
**/Dockerfile*
|
||||
**/node_modules
|
||||
**/npm-debug.log
|
||||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
LICENSE
|
||||
README.md
|
||||
25
IaC/RBLNews.Web/.dockerignore
Normal file
25
IaC/RBLNews.Web/.dockerignore
Normal file
@ -0,0 +1,25 @@
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/.project
|
||||
**/.settings
|
||||
**/.toolstarget
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/.idea
|
||||
**/*.*proj.user
|
||||
**/*.dbmdl
|
||||
**/*.jfm
|
||||
**/azds.yaml
|
||||
**/bin
|
||||
**/charts
|
||||
**/docker-compose*
|
||||
**/Dockerfile*
|
||||
**/node_modules
|
||||
**/npm-debug.log
|
||||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
LICENSE
|
||||
README.md
|
||||
29
IaC/RBLNews.Web/Dockerfile
Normal file
29
IaC/RBLNews.Web/Dockerfile
Normal file
@ -0,0 +1,29 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
EXPOSE 8080
|
||||
EXPOSE 443
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["../../RBLNews.Web/RBLNews.Shared.csproj", "RBLNews.Shared/"]
|
||||
RUN dotnet restore "RBLFeeder/RBLNews.Web.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/RBLNews.Web"
|
||||
RUN dotnet build "RBLNews.Web.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "RBLNews.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
|
||||
# set time zone
|
||||
RUN apt-get update && apt-get install -y tzdata
|
||||
ENV TZ=Europe/Berlin
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
ENTRYPOINT ["dotnet", "RBLNews.Web.dll"]
|
||||
@ -4,6 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user