Skip to content

Commit 787a884

Browse files
committed
feat: setup docker and github actions automation
1 parent 53ff923 commit 787a884

4 files changed

Lines changed: 58 additions & 1 deletion

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Build and Push Docker Image
2+
3+
# This triggers the automation every time you push to the 'main' branch
4+
on:
5+
push:
6+
branches: [ "main" ]
7+
8+
jobs:
9+
build-and-push:
10+
runs-on: ubuntu-latest
11+
steps:
12+
# 1. Gets your code onto the cloud server
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
# 2. Logs into GHCR using a GitHub Secret (Do not hardcode your token here!)
17+
- name: Log in to GitHub Container Registry
18+
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
19+
20+
# 3. Builds and pushes the image
21+
- name: Build and Push
22+
run: |
23+
docker-compose build
24+
docker push ghcr.io/<YOUR_GITHUB_USERNAME>/kvstore:latest

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM ubuntu:22.04
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt-get update && apt-get install -y \
6+
build-essential \
7+
cmake \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
WORKDIR /app
11+
12+
COPY . .
13+
14+
RUN cmake -S . -B build && cmake --build build
15+
16+
ENTRYPOINT ["./build/kvstore"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ A high-performance, fault-tolerant Distributed Key-Value Store built from scratc
3131
```bash
3232
mkdir build && cd build
3333
cmake ..
34-
make
34+
make

docker-compose.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: '3.8'
2+
services:
3+
node1:
4+
build: .
5+
image: ghcr.io/drakkkkk/kvstore:latest
6+
network_mode: "host"
7+
command: ["8080", "1"]
8+
node2:
9+
build: .
10+
image: ghcr.io/drakkkkk/kvstore:latest
11+
network_mode: "host"
12+
command: ["8081", "2"]
13+
node3:
14+
build: .
15+
image: ghcr.io/drakkkkk/kvstore:latest
16+
network_mode: "host"
17+
command: ["8082", "3"]

0 commit comments

Comments
 (0)