-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,20 @@ | ||
name: Publish Docker Images | ||
name: Build and Publish Image | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- development | ||
push: | ||
branches: [ development, staging ] | ||
branches: [development, staging] | ||
release: | ||
types: [ "published" ] | ||
workflow_dispatch: | ||
inputs: | ||
tagName: | ||
description: 'Tag of the image you want to build and push' | ||
required: true | ||
types: ["published"] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Prepare | ||
id: prep | ||
run: | | ||
DOCKER_IMAGE=cmusei/steamfitter-api | ||
VERSION=development | ||
if [[ ! -z "${{ github.event.inputs.tagName }}" ]]; then | ||
VERSION=${{ github.event.inputs.tagName }} | ||
TAGS="${DOCKER_IMAGE}:${VERSION}" | ||
elif [[ $GITHUB_REF == refs/tags/* ]]; then | ||
VERSION=${GITHUB_REF#refs/tags/} | ||
MAJORMINORVERSION=$(echo $VERSION | grep -oP '(\d+)\.(\d+)') | ||
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${MAJORMINORVERSION}" | ||
elif [[ $GITHUB_REF == refs/heads/* ]]; then | ||
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') | ||
TAGS="${DOCKER_IMAGE}:${VERSION}" | ||
fi | ||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | ||
echo ::set-output name=push::false | ||
echo "event is pull_request, not pushing image" | ||
else | ||
echo ::set-output name=push::true | ||
echo "event is not pull_request, pushing image" | ||
fi | ||
echo ::set-output name=version::${VERSION} | ||
echo ::set-output name=tags::${TAGS} | ||
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to DockerHub | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: ${{ steps.prep.outputs.push }} | ||
pull: true | ||
tags: ${{ steps.prep.outputs.tags }} | ||
labels: | | ||
org.opencontainers.image.source=${{ github.event.repository.clone_url }} | ||
org.opencontainers.image.created=${{ steps.prep.outputs.created }} | ||
org.opencontainers.image.revision=${{ github.sha }} | ||
build-and-publish: | ||
name: Build and Publish | ||
uses: cmu-sei/Crucible-Github-Actions/.github/workflows/[email protected] | ||
with: | ||
imageName: cmusei/steamfitter-api | ||
secrets: | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,27 @@ | ||
# | ||
#multi-stage target: dev | ||
# | ||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS dev | ||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS dev | ||
|
||
ENV ASPNETCORE_URLS=http://0.0.0.0:4302 \ | ||
ASPNETCORE_ENVIRONMENT=DEVELOPMENT | ||
ENV ASPNETCORE_HTTP_PORTS=4300 | ||
ENV ASPNETCORE_ENVIRONMENT=DEVELOPMENT | ||
|
||
# Must be copied above both steamfitter and stackstorm. Will not accept ../stackstorm.api for copying. | ||
COPY . /app | ||
WORKDIR /app/Steamfitter.Api | ||
|
||
WORKDIR /app | ||
RUN dotnet publish -c Release -o /app/dist | ||
|
||
CMD ["dotnet", "run"] | ||
|
||
# | ||
#multi-stage target: prod | ||
# | ||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS prod | ||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS prod | ||
ARG commit | ||
ENV COMMIT=$commit | ||
ENV DOTNET_HOSTBUILDER__RELOADCONFIGCHANGE=false | ||
COPY --from=dev /app/dist /app | ||
|
||
WORKDIR /app | ||
ENV ASPNETCORE_URLS=http://*:80 | ||
ENV ASPNETCORE_HTTP_PORTS=80 | ||
EXPOSE 80 | ||
CMD [ "dotnet", "Steamfitter.Api.dll" ] | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y jq | ||
CMD ["dotnet", "Steamfitter.Api.dll"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> | ||
<ProjectGuid>{0C65D9CC-A91F-46D5-BC1A-19A658064836}</ProjectGuid> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.2" /> | ||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -268,4 +268,3 @@ protected override void Down(MigrationBuilder migrationBuilder) | |
} | ||
} | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,4 +53,3 @@ protected override void Down(MigrationBuilder migrationBuilder) | |
} | ||
} | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.