Skip to content

Commit

Permalink
switched to self hosted mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
ipmanlk committed Apr 9, 2024
1 parent c059b6f commit ca9108f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
7 changes: 3 additions & 4 deletions compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
MYSQL_DATABASE: cn
MYSQL_ROOT_PASSWORD: "root"
ports:
- "3308:3306"
- "127.0.0.1:3308:3306"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
timeout: 20s
Expand All @@ -21,21 +21,20 @@ services:
dockerfile: Dockerfile
container_name: splash
ports:
- "8050:8050"
- "127.0.0.1:8050:8050"
networks:
- cn_network
deploy:
resources:
limits:
memory: 200M

cnapi:
build:
context: .
dockerfile: Dockerfile.dev
container_name: cnapi
ports:
- "3500:8080"
- "127.0.0.1:3500:8080"
depends_on:
mysql:
condition: service_healthy
Expand Down
20 changes: 17 additions & 3 deletions compose.prod.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
version: "3.6"
services:
mysql:
image: mysql:8
container_name: cndb
environment:
MYSQL_DATABASE: cn
MYSQL_ROOT_PASSWORD: "root"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
timeout: 20s
retries: 10
networks:
- cn_network

splash:
build:
context: ./scrape-it
dockerfile: Dockerfile
container_name: splash
restart: unless-stopped
ports:
- "8050:8050"
- "127.0.0.1:8050:8050"
networks:
- cn_network
deploy:
Expand All @@ -21,11 +34,12 @@ services:
container_name: cnapi
restart: unless-stopped
ports:
- "3500:8080"
- "127.0.0.1:3500:8080"
depends_on:
splash:
condition: service_started
env_file: ./env.prod
mysql:
condition: service_healthy
networks:
- cn_network

Expand Down
5 changes: 4 additions & 1 deletion extractor/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func isFetchingBlocked(article *common.Article) bool {
var splashURL = os.Getenv("SPLASH_URL")

func formatURL(url string, useSplash bool) string {
if splashURL == "" {
splashURL = "http://splash:8050"
}

if useSplash {
url = fmt.Sprintf("%s/?url=%s", splashURL, url)
}
Expand All @@ -95,7 +99,6 @@ func hasSkipQuery(article *common.Article, skipQueries []string) bool {
return false
}


// removeAttributes removes specified attributes from all elements in the given goquery.Selection.
func removeAttributes(selection *goquery.Selection, attributes ...string) {
for _, attribute := range attributes {
Expand Down
2 changes: 1 addition & 1 deletion sqldb/sqldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func InitDB() error {
dsn := os.Getenv("MYSQL_DSN")

if dsn == "" {
dsn = "root:@tcp(0.0.0.0:3306)/cn?charset=utf8mb4&parseTime=True&loc=Local"
dsn = "root:root@tcp(mysql:3306)/cn?charset=utf8mb4&parseTime=True&loc=Local"
}

var err error
Expand Down

0 comments on commit ca9108f

Please sign in to comment.