🔨 Add github actions
Some checks failed
Build and Push Dyson Sphere / build (push) Has been cancelled

This commit is contained in:
LittleSheep 2025-05-18 22:40:07 +08:00
parent a86a0fef37
commit 2fca5310be
3 changed files with 37 additions and 10 deletions

32
.github/workflows/docker-build.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: Build and Push Dyson Sphere
on:
push:
branches:
- master
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest # x86_64 (default), avoids arm64 native module issues
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: DysonNetwork.Sphere
push: true
tags: xsheep2010/dyson-sphere:latest
platforms: linux/amd64

View File

@ -0,0 +1 @@
node_modules

View File

@ -6,24 +6,18 @@ EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
# Install Node.js
RUN apt-get update && apt-get install -y curl
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm@latest
RUN apt-get update && apt-get install -y nodejs npm
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["DysonNetwork.Sphere/DysonNetwork.Sphere.csproj", "DysonNetwork.Sphere/"]
COPY ["DysonNetwork.Sphere.csproj", "DysonNetwork.Sphere/"]
RUN dotnet restore "DysonNetwork.Sphere/DysonNetwork.Sphere.csproj"
COPY . .
WORKDIR "/src/DysonNetwork.Sphere"
COPY . .
# Install npm packages and build Tailwind CSS
COPY ["DysonNetwork.Sphere/package*.json", "./"]
RUN npm install
COPY ["DysonNetwork.Sphere/postcss.config.js", "./"]
COPY ["DysonNetwork.Sphere/wwwroot/css/site.css", "./wwwroot/css/"]
RUN npx @tailwindcss/cli -i ./wwwroot/css/site.css -o ./wwwroot/css/styles.css
RUN npm run css:build
RUN dotnet build "DysonNetwork.Sphere.csproj" -c $BUILD_CONFIGURATION -o /app/build