Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit abf0acd

Browse files
committed
feat: cd action
1 parent 102aa86 commit abf0acd

6 files changed

Lines changed: 177 additions & 88 deletions

File tree

.github/workflows/cd.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Build and Publish Docker Images
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "v*"
9+
pull_request:
10+
branches:
11+
- main
12+
workflow_dispatch:
13+
14+
env:
15+
REGISTRY: ghcr.io
16+
OWNER: ${{ github.repository_owner }}
17+
18+
jobs:
19+
build-and-push:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
packages: write
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Log in to the Container registry
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ${{ env.REGISTRY }}
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Set version
40+
id: set-version
41+
run: |
42+
if [[ $GITHUB_REF == refs/tags/v* ]]; then
43+
VERSION=${GITHUB_REF#refs/tags/v}
44+
else
45+
VERSION=latest
46+
fi
47+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
48+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
49+
50+
- name: Build all images in parallel
51+
run: |
52+
docker compose -f docker-compose.build.yaml build --parallel
53+
54+
- name: Tag and push images
55+
run: |
56+
# Get all service names from docker-compose.build.yaml
57+
SERVICES=$(grep -E "^ [a-zA-Z0-9_-]+:" docker-compose.build.yaml | sed 's/://g' | awk '{print $1}')
58+
59+
# Tag and push each image
60+
for SERVICE in $SERVICES; do
61+
# Skip empty lines
62+
[ -z "$SERVICE" ] && continue
63+
64+
# Get the image name from docker-compose.build.yaml
65+
IMAGE_NAME=$(grep -A5 " $SERVICE:" docker-compose.build.yaml | grep "image:" | awk '{print $2}')
66+
67+
# Skip if no image name found
68+
[ -z "$IMAGE_NAME" ] && continue
69+
70+
echo "Processing $SERVICE with image $IMAGE_NAME"
71+
72+
# Tag with version and SHA
73+
GHCR_IMAGE="${REGISTRY}/${OWNER}/bashbuddy-${SERVICE}"
74+
SHA_TAG=$(echo ${{ github.sha }} | cut -c1-7)
75+
76+
docker tag $IMAGE_NAME $GHCR_IMAGE:$VERSION
77+
docker tag $IMAGE_NAME $GHCR_IMAGE:$SHA_TAG
78+
79+
# Push if not a PR
80+
if [[ "${{ github.event_name }}" != "pull_request" ]]; then
81+
docker push $GHCR_IMAGE:$VERSION
82+
docker push $GHCR_IMAGE:$SHA_TAG
83+
echo "Pushed $GHCR_IMAGE:$VERSION and $GHCR_IMAGE:$SHA_TAG"
84+
else
85+
echo "Skipping push for PR (would have pushed $GHCR_IMAGE:$VERSION and $GHCR_IMAGE:$SHA_TAG)"
86+
fi
87+
done

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ For little changes you won't need this, but if you're planning to make a big cha
5555
3. Start necessary services for development, such as postgres and dragonfly (redis):
5656

5757
```bash
58-
docker compose -f docker-comopse.db.yaml up
58+
docker compose up
5959
```
6060

6161
4. Start the project:

docker-compose.build.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
services:
2+
landing:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
target: landing
7+
image: socketless/landing
8+
restart: always
9+
env_file:
10+
- .env
11+
ports:
12+
- 3000
13+
14+
docs:
15+
build:
16+
context: .
17+
dockerfile: Dockerfile
18+
target: docs
19+
image: socketless/docs
20+
restart: always
21+
env_file:
22+
- .env
23+
ports:
24+
- 80
25+
26+
nextjs:
27+
build:
28+
context: .
29+
dockerfile: Dockerfile
30+
target: nextjs
31+
image: socketless/nextjs
32+
restart: always
33+
env_file:
34+
- .env
35+
ports:
36+
- 3000
37+
38+
connect:
39+
build:
40+
context: .
41+
dockerfile: Dockerfile
42+
target: connect
43+
image: socketless/connect
44+
restart: always
45+
env_file:
46+
- .env
47+
ports:
48+
- 3000
49+
deploy:
50+
mode: replicated
51+
replicas: 2
52+
endpoint_mode: dnsrr
53+
54+
master:
55+
build:
56+
context: .
57+
dockerfile: Dockerfile
58+
target: master
59+
image: socketless/master
60+
restart: always
61+
env_file:
62+
- .env
63+
ports:
64+
- 3000

docker-compose.db.yaml

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

docker-compose.yaml

Lines changed: 23 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,26 @@
11
services:
2-
landing:
3-
build:
4-
context: .
5-
dockerfile: Dockerfile
6-
target: landing
7-
image: socketless/landing
8-
restart: always
9-
env_file:
10-
- .env
2+
timescaledb:
3+
image: timescale/timescaledb:latest-pg16
4+
environment:
5+
# POSTGRES_USER: user
6+
POSTGRES_PASSWORD: password
7+
# POSTGRES_DB: socketless
118
ports:
12-
- 3000
13-
14-
docs:
15-
build:
16-
context: .
17-
dockerfile: Dockerfile
18-
target: docs
19-
image: socketless/docs
20-
restart: always
21-
env_file:
22-
- .env
9+
- 5432:5432
10+
volumes:
11+
- postgres-data:/var/lib/postgresql/data
12+
dragonfly:
13+
image: "docker.dragonflydb.io/dragonflydb/dragonfly"
14+
ulimits:
15+
memlock: -1
2316
ports:
24-
- 80
25-
26-
nextjs:
27-
build:
28-
context: .
29-
dockerfile: Dockerfile
30-
target: nextjs
31-
image: socketless/nextjs
32-
restart: always
33-
env_file:
34-
- .env
35-
ports:
36-
- 3000
37-
38-
connect:
39-
build:
40-
context: .
41-
dockerfile: Dockerfile
42-
target: connect
43-
image: socketless/connect
44-
restart: always
45-
env_file:
46-
- .env
47-
ports:
48-
- 3000
49-
deploy:
50-
mode: replicated
51-
replicas: 2
52-
endpoint_mode: dnsrr
53-
54-
master:
55-
build:
56-
context: .
57-
dockerfile: Dockerfile
58-
target: master
59-
image: socketless/master
60-
restart: always
61-
env_file:
62-
- .env
63-
ports:
64-
- 3000
17+
- "6379:6379"
18+
# For better performance, consider `host` mode instead `port` to avoid docker NAT.
19+
# `host` mode is NOT currently supported in Swarm Mode.
20+
# https://docs.docker.com/compose/compose-file/compose-file-v3/#network_mode
21+
# network_mode: "host"
22+
volumes:
23+
- dragonfly-data:/data
24+
volumes:
25+
dragonfly-data:
26+
postgres-data:

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
},
99
"scripts": {
1010
"build": "turbo run build",
11+
"build:docker": "docker compose -f docker-compose.build.yaml build --parallel",
12+
"build:env": "infisical run -env dev -- turbo build",
1113
"clean": "git clean -xdf node_modules",
1214
"clean:workspaces": "turbo run clean",
1315
"db:push": "turbo -F @socketless/db push",

0 commit comments

Comments
 (0)