Skip to content

Commit

Permalink
Merge branch 'main' into role-authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
Ftm-Sayadzadeh committed Aug 27, 2024
2 parents b756062 + d293aad commit 6e213bd
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 14 deletions.
26 changes: 16 additions & 10 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ jobs:
with:
dotnet-version: 8.0.x

- name: Check formatting
id: lint
continue-on-error: true
run: dotnet format --verify-no-changes

- name: Install dependencies
run: dotnet restore

Expand All @@ -43,8 +38,19 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Fail if linting failed
if: steps.lint.outcome == 'failure'
run: |
echo "Linting failed. Failing the workflow."
exit 1
- name: Lint
id: lint
continue-on-error: true
run: dotnet format --verify-no-changes


- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build the Docker image
uses: docker/build-push-action@v3
with:
push: false
context: "{{defaultContext}}:mohaymen-codestar-Team02"
tags: mohaymen-codestar-team02
labels:
7 changes: 7 additions & 0 deletions mohaymen-codestar-Team02/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bin/
obj/
.idea/
appsettings.Development.json
*.Env
*.env
Dockerfile
12 changes: 9 additions & 3 deletions mohaymen-codestar-Team02/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /app

ENV PATH="${PATH}:/root/.dotnet/tools"
RUN dotnet tool install --global dotnet-ef

COPY *.csproj .
RUN dotnet restore

COPY . .
RUN dotnet publish -c Release -o output
RUN dotnet build -c Release
RUN dotnet publish -c Release -o output --no-build
RUN dotnet ef migrations bundle -o dbmigrate
# </Build>

# <Run>
Expand All @@ -19,9 +24,10 @@ USER app

WORKDIR /app

COPY --chown=app:app --from=build /app/output .
COPY --chown=app:app --from=build /app/output /app/dbmigrate /app/
COPY --chown=app:app ./entrypoint.sh /app/entrypoint.sh

ENTRYPOINT ["dotnet", "mohaymen-codestar-Team02.dll"]
ENTRYPOINT ["bash", "/app/entrypoint.sh"]

EXPOSE 8080

Expand Down
28 changes: 28 additions & 0 deletions mohaymen-codestar-Team02/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -e

BASE_DIR=$(dirname "$0")

migrate() {
echo "Migrating database"
"${BASE_DIR}/dbmigrate" $@
}

run() {
echo "Running application"
dotnet "$BASE_DIR/mohaymen-codestar-Team02.dll"
}

case "$1" in
migrate)
additional_args=${@:2}
migrate $additional_args
;;
run)
run
;;
*)
migrate
run
;;
esac
2 changes: 1 addition & 1 deletion mohaymen-codestar-Team02/prod.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ASPNETCORE_ENVIRONMENT=Release
ConnectionStrings__DefaultConnection="Host=postgres;Port=5432;Database=mohaymen_group02_project;Username=pguser;Password=pgpass;"
CONNECTION_STRING="Host=postgres;Port=5432;Database=mohaymen_group02_project;Username=pguser;Password=pgpass;"

0 comments on commit 6e213bd

Please sign in to comment.