Skip to content

Commit 89e03ee

Browse files
authored
Merge pull request #1 from javeoff/main
Add Makefile with Docker container management commands
2 parents c97faf6 + 3cfb99d commit 89e03ee

10 files changed

Lines changed: 226 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Docker Publish
2+
3+
on:
4+
5+
workflow_run:
6+
workflows: ["Release"]
7+
types:
8+
- completed
9+
branches:
10+
- main
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_NAME: ${{ github.repository }}
15+
16+
jobs:
17+
build-and-push:
18+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v3
27+
28+
- name: Log in to the Container registry
29+
uses: docker/login-action@v2
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Extract metadata (tags, labels) for Docker
36+
id: meta
37+
uses: docker/metadata-action@v4
38+
with:
39+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
40+
tags: |
41+
type=ref,event=branch
42+
type=ref,event=pr
43+
type=semver,pattern={{version}}
44+
type=semver,pattern={{major}}.{{minor}}
45+
type=sha
46+
47+
- name: Build and push Docker image
48+
uses: docker/build-push-action@v4
49+
with:
50+
context: .
51+
push: ${{ github.event_name != 'pull_request' }}
52+
tags: ${{ steps.meta.outputs.tags }}
53+
labels: ${{ steps.meta.outputs.labels }}
54+
build-args: |
55+
GH_TOKEN=${{ secrets.GH_TOKEN }}
56+

.github/workflows/release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
release:
9+
name: Release
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
issues: write # for commenting on issues
14+
pull-requests: write # for commenting on PRs
15+
id-token: write # for authentication
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 'lts/*'
26+
27+
- name: Install dependencies
28+
run: npm i
29+
env:
30+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
31+
32+
- name: Release
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
35+
run: npm run release

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.aider*

.releaserc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"branches": ["main"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
"@semantic-release/changelog",
7+
"@semantic-release/github",
8+
["@semantic-release/git", {
9+
"assets": ["package.json", "CHANGELOG.md"],
10+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
11+
}]
12+
]
13+
}
14+

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# [1.1.0](https://github.com/javeoff/cloudscraper-server/compare/v1.0.0...v1.1.0) (2025-02-08)
2+
3+
4+
### Features
5+
6+
* **docker:** add docker-compose file to simplify application deployment and configuration ([bb79d1a](https://github.com/javeoff/cloudscraper-server/commit/bb79d1ad109078c9ac7198a758006161bed8717b))
7+
8+
# 1.0.0 (2025-02-08)
9+
10+
11+
### Features
12+
13+
* Add Makefile with Docker container management commands ([1557166](https://github.com/javeoff/cloudscraper-server/commit/155716643e15ba2ab16ed84d7fbe97941444f6d8))
14+
* **workflows:** add Docker Publish and Release workflows for automated image building and deployment ([112a293](https://github.com/javeoff/cloudscraper-server/commit/112a2939eed6c8bc1a18d07f3dbd43fcaa99354a))

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM python:3.11-slim
2+
3+
WORKDIR /app
4+
5+
# Install system dependencies
6+
# RUN apt-get update && apt-get install -y \
7+
# gcc \
8+
# && rm -rf /var/lib/apt/lists/*
9+
10+
# Copy requirements first to leverage Docker cache
11+
COPY requirements.txt .
12+
RUN pip install --no-cache-dir -r requirements.txt
13+
14+
# Copy application code
15+
COPY server.py .
16+
17+
# Expose the port the app runs on
18+
EXPOSE 5000
19+
20+
# Command to run the application
21+
CMD ["python", "server.py"]

Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.PHONY: build run clean logs test
2+
3+
# Переменные
4+
IMAGE_NAME = proxy-server
5+
CONTAINER_NAME = proxy-server
6+
PORT = 5000
7+
8+
# Сборка Docker образа
9+
build:
10+
docker build -t $(IMAGE_NAME) .
11+
12+
# Запуск контейнера
13+
run:
14+
docker run -d --name $(CONTAINER_NAME) -p $(PORT):$(PORT) $(IMAGE_NAME)
15+
16+
# Остановка и удаление контейнера
17+
clean:
18+
docker stop $(CONTAINER_NAME) || true
19+
docker rm $(CONTAINER_NAME) || true
20+
21+
# Просмотр логов
22+
logs:
23+
docker logs -f $(CONTAINER_NAME)
24+
25+
# Перезапуск контейнера
26+
restart: clean run
27+
28+
# Сборка и запуск
29+
up: build run
30+
31+
# Проверка статуса контейнера
32+
status:
33+
docker ps -a | grep $(CONTAINER_NAME)

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,31 @@ if __name__ == "__main__":
3535
serve(app, host="0.0.0.0", port=5000) # change the port here
3636
```
3737
Feel free to configure flask or other options to suite your needs
38+
39+
## Using Make Commands
40+
The project includes several Make commands to help manage the Docker container:
41+
42+
```bash
43+
# Build the Docker image
44+
make build
45+
46+
# Run the container
47+
make run
48+
49+
# Build and run in one command
50+
make up
51+
52+
# Stop and remove the container
53+
make clean
54+
55+
# View container logs
56+
make logs
57+
58+
# Restart the container
59+
make restart
60+
61+
# Check container status
62+
make status
63+
```
64+
65+
You can change the port and container settings by editing the variables at the top of the Makefile.

docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
services:
2+
app:
3+
image: ghcr.io/GhostTypes/cloudscraper-server:main
4+
ports:
5+
- 5000:5000

package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "cs",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"release": "semantic-release"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC",
12+
"devDependencies": {
13+
"@semantic-release/changelog": "^6.0.3",
14+
"@semantic-release/commit-analyzer": "^13.0.0",
15+
"@semantic-release/git": "^10.0.1",
16+
"@semantic-release/github": "^9.2.6",
17+
"@semantic-release/release-notes-generator": "^14.0.1"
18+
}
19+
}

0 commit comments

Comments
 (0)