Skip to content

Commit 7d17783

Browse files
committed
feat: docker build for whatifrussian/website
1 parent 706c996 commit 7d17783

File tree

6 files changed

+97
-16
lines changed

6 files changed

+97
-16
lines changed

.github/workflows/ci.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI Build
2+
3+
on:
4+
push:
5+
branches: [master]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-ci:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
steps:
16+
- uses: actions/checkout@v4
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: Build and push CI Docker image
26+
run: |
27+
IMAGE=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
28+
docker build --build-arg BUILD_MODE=ci -t $IMAGE:ci .
29+
docker push $IMAGE:ci

.github/workflows/release.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Build and Push Docker Image on Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-and-push:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Log in to GitHub Container Registry
20+
uses: docker/login-action@v3
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Extract tag name
27+
id: vars
28+
run: |
29+
TAG=${GITHUB_REF#refs/tags/}
30+
echo "tag=${TAG}" >> $GITHUB_OUTPUT
31+
32+
- name: Build Docker image
33+
run: |
34+
IMAGE=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
35+
docker build --build-arg BUILD_MODE=dev -t $IMAGE:dev-${{ steps.vars.outputs.tag }} -t $IMAGE:latest-dev .
36+
docker build --build-arg BUILD_MODE=prod -t $IMAGE:${{ steps.vars.outputs.tag }} -t $IMAGE:latest .
37+
38+
- name: Push Docker image
39+
run: |
40+
IMAGE=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
41+
docker push $IMAGE:dev-${{ steps.vars.outputs.tag }}
42+
docker push $IMAGE:${{ steps.vars.outputs.tag }}
43+
docker push $IMAGE:latest-dev
44+
docker push $IMAGE:latest

.travis.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM python:3.5-slim AS builder
2+
3+
WORKDIR /site
4+
ARG BUILD_MODE=prod
5+
ENV BUILD_MODE=${BUILD_MODE}
6+
7+
RUN apt-get update && apt-get install -y --no-install-recommends \
8+
build-essential \
9+
libxml2-dev \
10+
libxslt1-dev \
11+
zlib1g-dev \
12+
openssh-client \
13+
&& rm -rf /var/lib/apt/lists/*
14+
COPY requirements.txt .
15+
RUN pip install --no-cache-dir -r requirements.txt
16+
COPY . .
17+
RUN fab build:${BUILD_MODE}
18+
19+
FROM alpine:latest AS final
20+
21+
COPY --from=builder /site/output /output
22+
23+
ENTRYPOINT ["sh", "-c", "cp -r /output/* /mnt && echo '✅ Copy done' || (echo '❌ Copy failed' && exit 1)"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://travis-ci.org/whatifrussian/website.svg)](https://travis-ci.org/whatifrussian/website)
1+
![Release Status](https://github.com/whatifrussian/website/actions/workflows/release.yml/badge.svg)
22

33
## Useful links
44

ci.chtoes.li.enc

-2.56 KB
Binary file not shown.

0 commit comments

Comments
 (0)