This is a viewer only at the moment see the article on how this works.
To update the preview hit Ctrl-Alt-R (or ⌘-Alt-R on Mac) or Enter to refresh. The Save icon lets you save the markdown file to disk
This is a preview from the server running through my markdig pipeline
डॉकर छवि बनाने और दबाने के लिए जीटहब क्रियाओं का उपयोग
Tuesday, 30 July 2024
यह कन्टेनर रजिस्ट्री में डॉकर छवि बनाने और दबाने के लिए GitHub कार्यों का उपयोग करने की एक सरल उदाहरण है
पूर्व आवश्यकताएं
- एक डकर फ़ाइल मौजूद है जो आप बनाना चाहते हैं और दबाएँ
- परियोजना के लिए एक GitHub रिपोजिटरी मौजूद है
- छवि को '.' में दबाने के लिए एक कन्टेनर रजिस्ट्री मौजूद है
- डोकर रजिस्ट्री
इस परियोजना के लिए मैंने मूल .NET कोर ASP.NET परियोजना और राइडर द्वारा बनाया गया डिफ़ॉल्ट Dockerfile से शुरू किया
डॉकरेबल
यह Dockerfile एक बहु-स्तंभ निर्माण है जो परियोजना बनाता है और फिर रनटाइम छवि में आउटपुट को प्रतिलिपि करता है
इस proect के लिए मैं TailwindCSS का उपयोग कर रहा हूँ , मैं भी नोड को स्थापित करने की जरूरत है . js और Tail windCSS निर्माण कमांड चलाएँ
# Install Node.js v20.x
RUN apt-get update && apt-get install -y curl \
&& curl -fsSL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh \
&& bash nodesource_setup.sh \
&& apt-get install -y nodejs \
&& rm -f nodesource_setup.sh \
&& rm -rf /var/lib/apt/lists/*
यह नोड की नवीनतम (लिखने के समय )संस्करण को डाउनलोड करता है और इसे निर्माण छवि में स्थापित करता है
फ़ाइल में बाद में
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
# Install Node.js v20.x
RUN apt-get update && apt-get install -y curl \
&& curl -fsSL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh \
&& bash nodesource_setup.sh \
&& apt-get install -y nodejs \
&& rm -f nodesource_setup.sh \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY ["Mostlylucid/Mostlylucid.csproj", "Mostlylucid/"]
RUN dotnet restore "Mostlylucid/Mostlylucid.csproj"
COPY . .
WORKDIR "/src/Mostlylucid"
# Copy package.json and package-lock.json and install npm dependencies
COPY package*.json ./
RUN npm install
# Ensure npm-run-all is available and install npm dependencies
RUN npm --version
RUN npx tailwindcss -i ./src/css/main.css -o ./wwwroot/css/dist/main.css
RUN dotnet build "Mostlylucid.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
RUN dotnet publish "Mostlylucid.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Mostlylucid.dll"]
GitHub क्रियाएँ
इस साइट के लिए GitHub कार्य एक सरल निर्माण और push क्रिया है जो मुख्य शाखा में एक push पर ट्रिगर किया जाता है https://github.comMSC2scottgalM SK3mostlylucidwebMSSK4blobMST5mainMS/.gitHubMSP7workflowsM/dockerMPSK9imageMSSK10yml
यह क्रिया रिपोजिटर की जाँच करती है, डोकर हब में लॉग करता है , Docker Buildx को सेटअप करता है
डॉकर संयोजन फ़ाइल में
name: Docker Image CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USER_NAME }}" --password-stdin
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and tag the Docker image
id: build
run: |
TIMESTAMP=$(date +%s)
echo "TIMESTAMP=$TIMESTAMP" >> $GITHUB_ENV
docker build . --file Mostlylucid/Dockerfile --tag ${{ secrets.DOCKER_HUB_USER_NAME }}/mostlylucid:latest --tag ${{ secrets.DOCKER_HUB_USER_NAME }}/mostlylucid:$TIMESTAMP
- name: Push the Docker image to Docker Hub
run: |
docker push ${{ secrets.DOCKER_HUB_USER_NAME }}/mostlylucid:latest
docker push ${{ secrets.DOCKER_HUB_USER_NAME }}/mostlylucid:${{ env.TIMESTAMP }}