Skip to content

Commit

Permalink
Merge pull request #29 from D0nKarnag3/feature/containerize
Browse files Browse the repository at this point in the history
Feature/containerize
  • Loading branch information
Hviid authored Oct 28, 2021
2 parents dd0619f + 9bf2c1e commit 318d1ac
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build and publish docker image

on:
pull_request:
push:
branches:
- 'master'

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push to Docker hub
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: hviid84/dbmigrator:latest
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM mcr.microsoft.com/dotnet/runtime:5.0.11-alpine3.14-amd64 AS base
WORKDIR /app
RUN apk add --no-cache icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false

FROM mcr.microsoft.com/dotnet/sdk:5.0.402-alpine3.14-amd64 AS build

WORKDIR /src
COPY ./DBMigrator.Console/DBMigrator.Console.csproj DBMigrator.Console/DBMigrator.Console.csproj
COPY ./DBMigrator/DBMigrator.csproj DBMigrator/DBMigrator.csproj
COPY ./DBMigrator.Test/DBMigrator.Test.csproj DBMigrator.Test/DBMigrator.Test.csproj
RUN dotnet restore -f DBMigrator.Console/DBMigrator.Console.csproj

COPY ../ .
RUN dotnet build -c Release -o /app DBMigrator.Console/DBMigrator.Console.csproj

FROM build AS test

RUN dotnet test

FROM base AS final

WORKDIR /app
COPY --from=build /app .
ENTRYPOINT [ "dotnet", "DBMigrator.Console.dll" ]

0 comments on commit 318d1ac

Please sign in to comment.