Skip to content

Commit 07cb2d1

Browse files
committed
initiate new workflows
1 parent 412c244 commit 07cb2d1

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build and Push the Docker Image
2+
3+
on:
4+
push:
5+
branches: ["master"]
6+
7+
permissions:
8+
contents: read
9+
packages: write
10+
11+
jobs:
12+
build-and-push:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v5
17+
18+
- name: Log in to GitHub Container Registry
19+
uses: docker/login-action@v3
20+
with:
21+
registry: ghcr.io
22+
username: ${{ github.actor }}
23+
password: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
28+
- name: Build and Push
29+
uses: docker/build-push-action@v5
30+
with:
31+
context: .
32+
file: ./Dockerfile
33+
push: true
34+
tags: |
35+
ghcr.io/${{ github.repository_owner }}/blog:latest
36+
ghcr.io/${{ github.repository_owner }}/blog:${{ github.sha }} # Optional: Tag with commit SHA
37+
cache-from: type=gha
38+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Stage 1: The Builder
2+
# Use a full Ruby image to build the Jekyll site
3+
FROM ruby:3.2.3-alpine AS builder
4+
5+
RUN apk add --no-cache --update build-base git
6+
# Install dependencies
7+
WORKDIR /app
8+
COPY Gemfile Gemfile.lock ./
9+
RUN bundle config set deployment 'true' && \
10+
bundle config set without 'development test' && \
11+
bundle install
12+
13+
# Build the site
14+
COPY . .
15+
RUN JEKYLL_ENV=production bundle exec jekyll b
16+
17+
# Stage 2: The Web Server
18+
# Use a tiny web server image for the final output
19+
FROM nginx:alpine
20+
21+
# Remove default nginx site
22+
RUN rm -rf /usr/share/nginx/html/*
23+
24+
# Copy *only the built site* from the previous "builder" stage
25+
COPY --from=builder /app/_site /usr/share/nginx/html
26+
27+
# nginx runs on port 80 by default
28+
EXPOSE 80

0 commit comments

Comments
 (0)