Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*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
18 changes: 18 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Docker Image CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file BeGeneric/Dockerfile --tag begeneric:$(date +%s)
19 changes: 19 additions & 0 deletions BeGeneric/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["BeGeneric/BeGeneric.csproj", "BeGeneric/"]
RUN dotnet restore "BeGeneric/BeGeneric.csproj"
COPY . .
WORKDIR "/src/BeGeneric"
RUN dotnet build "BeGeneric.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "BeGeneric.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "BeGeneric.dll"]
4 changes: 3 additions & 1 deletion BeGeneric/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
}
},
"ConnectionStrings": {
"connectionString": "Server=localhost;Database=BeGenericSample;Integrated Security=SSPI"
//"connectionString": "Server=localhost;Database=BeGenericSample;Integrated Security=SSPI",
//docker config
"connectionString": "Server=host.docker.internal,1433;Database=BeGenericSample;User Id=sa;Password=Password123;"
},
"Jwt": {
"Key": "ThisismySecretKey",
Expand Down
20 changes: 20 additions & 0 deletions BeGeneric/sql/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use the official Microsoft SQL Server image as the base image
FROM mcr.microsoft.com/mssql/server:latest

# Set the working directory in the container to /app
WORKDIR /app

# Copy the initialization script to the /app directory in the container
COPY ./BeGeneric/sql /app
RUN ls

# Set the environment variable for the SA password
ENV ACCEPT_EULA=Y \
SA_PASSWORD=Password123


EXPOSE 1433

# Run the initialization script when the container starts
CMD /bin/bash entrypoint.sh & /opt/mssql/bin/sqlservr

3 changes: 3 additions & 0 deletions BeGeneric/sql/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sleep 20
echo "wait 20 seconds"
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P $SA_PASSWORD -i init.sql
Loading