-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ops/workflows
- Loading branch information
Showing
23 changed files
with
684 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
MSSQL_INITIAL_DATABASE="sip" | ||
MSSQL_SA_PASSWORD="Your_password123" | ||
ACCEPT_EULA="Y" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ASPNETCORE_ENVIRONMENT="Development" | ||
ApiKeys__0='{\"userName\": \"apikey\",\"apiKey\": \"apikey\"}' | ||
ConnectionStrings__DefaultConnection="Data Source=db;Initial Catalog=sip;persist security info=True;User id=sa;Password=Your_password123" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Continuous delivery (development) | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-and-push-image-development: | ||
name: Build and push image development | ||
environment: dev | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Azure Container Registry login | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DEVELOPMENT_AZURE_ACR_CLIENTID }} | ||
password: ${{ secrets.DEVELOPMENT_AZURE_ACR_SECRET }} | ||
registry: ${{ secrets.DEVELOPMENT_ACR_URL }} | ||
|
||
- name: Prepare tags | ||
id: prepare-tags | ||
run: | | ||
DOCKER_IMAGE=${{ secrets.DEVELOPMENT_ACR_URL }}/tramsapi-app | ||
VERSION=latest | ||
TAGS="${DOCKER_IMAGE}:${VERSION}" | ||
if [ "${{ github.event_name }}" = "push" ]; then | ||
VERSION=sha-${GITHUB_SHA} | ||
TAGS="$TAGS,${DOCKER_IMAGE}:${VERSION}" | ||
fi | ||
echo "tags=${TAGS}" >> $GITHUB_OUTPUT | ||
echo "deploy-version=${VERSION}" >> $GITHUB_OUTPUT | ||
- name: Push image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ steps.prepare-tags.outputs.tags }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
FROM mcr.microsoft.com/dotnet/sdk:3.1-bullseye AS build | ||
WORKDIR /build | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
COPY . . | ||
|
||
RUN mkdir -p /app/SQL | ||
RUN touch /app/SQL/DbMigrationScriptLegacy.sql | ||
RUN touch /app/SQL/DbMigrationScript.sql | ||
|
||
RUN dotnet restore TramsDataApi.sln | ||
RUN dotnet new tool-manifest | ||
RUN dotnet tool install dotnet-ef --version 6.0.5 | ||
ENV PATH="$PATH:/root/.dotnet/tools" | ||
|
||
RUN dotnet ef migrations script --output /app/SQL/DbMigrationScriptLegacy.sql --project TramsDataApi --context TramsDataApi.DatabaseModels.LegacyTramsDbContext --idempotent -v | ||
RUN dotnet ef migrations script --output /app/SQL/DbMigrationScript.sql --project TramsDataApi --context TramsDataApi.DatabaseModels.TramsDbContext --idempotent --no-build -v | ||
|
||
# this build has no effect on ef migrations because it is a "Release" configuration | ||
RUN dotnet build -c Release TramsDataApi.sln --no-restore | ||
RUN dotnet publish TramsDataApi -c Release -o /app --no-restore | ||
|
||
ARG ASPNET_IMAGE_TAG | ||
FROM mcr.microsoft.com/dotnet/aspnet:3.1-bullseye-slim AS final | ||
|
||
RUN apt-get update | ||
RUN apt-get install unixodbc curl gnupg -y | ||
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - | ||
RUN curl https://packages.microsoft.com/config/debian/11/prod.list | tee /etc/apt/sources.list.d/msprod.list | ||
RUN apt-get update | ||
RUN ACCEPT_EULA=Y apt-get install msodbcsql18 mssql-tools18 -y | ||
|
||
COPY --from=build /app /app | ||
|
||
WORKDIR /app | ||
COPY ./script/web-docker-entrypoint.sh ./docker-entrypoint.sh | ||
RUN chmod +x ./docker-entrypoint.sh | ||
EXPOSE 80/tcp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
version: "3.8" | ||
services: | ||
webapi: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
command: /bin/bash -c "./docker-entrypoint.sh dotnet TramsDataApi.dll" | ||
ports: | ||
- 80:80/tcp | ||
restart: always | ||
depends_on: | ||
- db | ||
- sqlcmd | ||
env_file: | ||
- .env.development | ||
networks: | ||
- dev | ||
|
||
db: | ||
image: mcr.microsoft.com/azure-sql-edge:latest | ||
env_file: .env.database | ||
ports: | ||
- 1433:1433 | ||
networks: | ||
- dev | ||
|
||
sqlcmd: | ||
image: mcr.microsoft.com/mssql-tools:latest | ||
env_file: .env.database | ||
command: /etc/docker-entrypoint.sh | ||
depends_on: | ||
- db | ||
stdin_open: true | ||
volumes: | ||
- ./script/sqlcmd-docker-entrypoint.sh:/etc/docker-entrypoint.sh | ||
networks: | ||
- dev | ||
|
||
networks: | ||
dev: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
# exit on failures | ||
set -e | ||
set -o pipefail | ||
|
||
MSSQL_INITIAL_DATABASE="${MSSQL_INITIAL_DATABASE:?}" | ||
|
||
echo "CREATE DATABASE $MSSQL_INITIAL_DATABASE;" > ./setup.sql | ||
echo "GO" >> ./setup.sql | ||
|
||
echo "Creating initial database ..." | ||
until /opt/mssql-tools/bin/sqlcmd -S db -U sa -P "$MSSQL_SA_PASSWORD" -d master -i ./setup.sql | ||
do | ||
echo "not ready yet..." | ||
sleep 1 | ||
done | ||
|
||
rm ./setup.sql | ||
|
||
echo "Created database $MSSQL_INITIAL_DATABASE ..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
# exit on failures | ||
set -e | ||
set -o pipefail | ||
|
||
ConnectionStrings__DefaultConnection=${ConnectionStrings__DefaultConnection:?} | ||
|
||
declare -A mysqlconn | ||
|
||
for keyvaluepair in $(echo "$ConnectionStrings__DefaultConnection" | sed "s/ //g; s/;/ /g") | ||
do | ||
IFS=" " read -r -a ARR <<< "${keyvaluepair//=/ }" | ||
mysqlconn[${ARR[0]}]=${ARR[1]} | ||
done | ||
|
||
echo "Running TramsDbContext database migrations ..." | ||
until /opt/mssql-tools18/bin/sqlcmd -S "${mysqlconn[Server]}" -U "${mysqlconn[UserId]}" -P "${mysqlconn[Password]}" -d "${mysqlconn[Database]}" -C -i /app/SQL/DbMigrationScript.sql -o /app/SQL/DbMigrationScriptOutput.txt | ||
do | ||
cat /app/SQL/DbMigrationScriptOutput.txt | ||
echo "Retrying database migrations ..." | ||
sleep 5 | ||
done | ||
|
||
echo "Running LegacyTramsDbContext database migrations ..." | ||
until /opt/mssql-tools18/bin/sqlcmd -S "${mysqlconn[Server]}" -U "${mysqlconn[UserId]}" -P "${mysqlconn[Password]}" -d "${mysqlconn[Database]}" -C -i /app/SQL/DbMigrationScriptLegacy.sql -o /app/SQL/DbMigrationScriptOutputLegacy.txt | ||
do | ||
cat /app/SQL/DbMigrationScriptOutputLegacy.txt | ||
echo "Retrying database migrations ..." | ||
sleep 5 | ||
done | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
formatter: "markdown table" | ||
version: "~> 0.16" | ||
settings: | ||
anchor: true | ||
default: true | ||
description: false | ||
escape: true | ||
hide-empty: false | ||
html: true | ||
indent: 2 | ||
lockfile: true | ||
read-comments: true | ||
required: true | ||
sensitive: true | ||
type: true | ||
sort: | ||
enabled: true | ||
by: name | ||
output: | ||
file: README.md | ||
mode: inject | ||
template: |- | ||
<!-- BEGIN_TF_DOCS --> | ||
{{ .Content }} | ||
<!-- END_TF_DOCS --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.3.7 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
brew "tfenv" | ||
brew "terraform-docs" | ||
brew "tfsec" | ||
brew "az" | ||
brew "coreutils" | ||
brew "jq" |
Oops, something went wrong.