Skip to content

Commit ea0f19b

Browse files
authored
Merge pull request #6 from cweidner3/ci
Implementing CI building
2 parents 6e85f67 + f6dc6e9 commit ea0f19b

File tree

4 files changed

+94
-3
lines changed

4 files changed

+94
-3
lines changed

.github/workflows/build-images.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build Docker Images CI
2+
3+
on:
4+
push:
5+
branches:
6+
- 'feature/**'
7+
- ci
8+
9+
jobs:
10+
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Build the Web image
18+
run: docker build web --file web/Dockerfile.prod --tag hikeblog-web:$(date +%s)
19+
20+
- name: Build the Api image
21+
run: docker build api --file api/Dockerfile.prod --tag hikeblog-api:$(date +%s)

.github/workflows/push-images.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Build and Publish Docker Images CI
2+
3+
on:
4+
push:
5+
branches:
6+
- $default-branch
7+
- ci
8+
tags:
9+
- 'v*'
10+
pull_request:
11+
branches:
12+
- $default-branch
13+
14+
jobs:
15+
16+
publish:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
- name: Set up QEMU
23+
uses: docker/setup-qemu-action@v2
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v2
27+
28+
- name: Log in to Docker Hub
29+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
30+
with:
31+
username: ${{ secrets.DOCKER_HUB_USER }}
32+
password: ${{ secrets.DOCKER_HUB_KEY }}
33+
34+
- name: Extract metadata (tags, labels) for Docker
35+
id: metaweb
36+
uses: docker/[email protected]
37+
with:
38+
images: ${{ secrets.DOCKER_HUB_NS }}/hikeblog-web
39+
40+
- name: Extract metadata (tags, labels) for Docker
41+
id: metaapi
42+
uses: docker/[email protected]
43+
with:
44+
images: ${{ secrets.DOCKER_HUB_NS }}/hikeblog-api
45+
tags: |
46+
type=ref,event=branch
47+
type=ref,event=pr
48+
type=semver,pattern={{version}}
49+
type=semver,pattern={{major}}.{{minor}}
50+
51+
- name: Build and push Web Docker image
52+
uses: docker/[email protected]
53+
with:
54+
context: web
55+
file: ./web/Dockerfile.prod
56+
push: true
57+
tags: ${{ steps.metaweb.outputs.tags }}
58+
labels: ${{ steps.metaweb.outputs.labels }}
59+
60+
- name: Build and push Docker image
61+
uses: docker/[email protected]
62+
with:
63+
context: api
64+
file: ./api/Dockerfile.prod
65+
push: true
66+
tags: ${{ steps.metaapi.outputs.tags }}
67+
labels: ${{ steps.metaapi.outputs.labels }}

api/Dockerfile.prod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM --platform=$BUILDPLATFORM python:3.11
1+
# FROM --platform=$BUILDPLATFORM python:3.11
2+
FROM python:3.11
23

34
RUN apt update -y && apt install -y \
45
gcc openssl \

web/Dockerfile.prod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM --platform=$BUILDPLATFORM node:18.2.0 as build
1+
# FROM --platform=$BUILDPLATFORM node:18.2.0 as build
2+
FROM node:18.2.0 as build
23

34
WORKDIR /build
45
COPY package.json ./
@@ -11,7 +12,8 @@ RUN npm run build
1112

1213
################################################################################
1314

14-
FROM --platform=$BUILDPLATFORM nginx:1.23.2
15+
# FROM --platform=$BUILDPLATFORM nginx:1.23.2
16+
FROM nginx:1.23.2
1517

1618
ENV NODE_ENV=production
1719

0 commit comments

Comments
 (0)