Skip to content

Commit

Permalink
Support for running screenshot on localhost
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Sandor committed Oct 17, 2024
1 parent ea763e5 commit 981f004
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ POSTGRES_DB=findfirst
SPRING_PROFILES_ACTIVE=dev
SPRING_DATASOURCE_USERNAME=$POSTGRES_USER
SPRING_DATASOURCE_PASSWORD=$POSTGRES_PASSWORD
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/findfirst
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/findfirst
SCREENSHOT_SERVICE_URL=http://screenshot:8080/
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/findfirst
- SPRING_PROFILES_ACTIVE=dev
- SPRING_MAIL_HOST=mail
- SCREENSHOT_SERVICE_URL=http://screenshot:8080/
- SCREENSHOT_SERVICE_URL=${SCREENSHOT_SERVICE_URL}
- FINDFIRST_SCREENSHOT_LOCATION=/app/screenshots
volumes:
- ./data/screenshots:/app/screenshots
Expand Down
26 changes: 26 additions & 0 deletions docs/README.dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,33 @@ host and docker without any problems.
- etc.
- The project does hot reload well, if the
IDE your using supports it with the JDTLS.
- Create another terminal tab
- `cd screenshot`
- `./gradlew bootRun`
- Open browser navigate to localhost:3000
- Create a user or use the test account:
- Username: jsmith
- password: test

### Partial Host/Docker Compose

- The application supports running the app in a mixed
environment. For example running everything but
the backend in docker compose:

```bash
docker compose db frontend mail screenshot
```

Then executing: `cd server && ./gradlew bootRun`

One exception is from the backend in docker compose
communicating with the screenshot service running on
host.

```bash
export SCREENSHOT_SERVICE_URL=http://172.17.0.1:8080
docker compose up mail server db frontend
```

This will allow the backend to reach localhost where the screenshot service is running.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public String takeScreenshot(@RequestParam String url) {

url = URLDecoder.decode(url, StandardCharsets.UTF_8);
String cleanUrl = url.replaceAll("http[s]://", "").replace("/", "_");
cleanUrl = cleanUrl.replaceAll("[*\"/\\<>:|?]+", "");

Path filePath = Path.of(screenshotSaveLoc, cleanUrl + ".png");
page.screenshot(new Page.ScreenshotOptions().setPath(filePath));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package dev.findfirst.core.service;

import java.util.ArrayList;
import java.util.List;

import dev.findfirst.core.model.Bookmark;
import dev.findfirst.core.model.Tag;
import dev.findfirst.core.repository.TagRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SearchService {

Expand Down

0 comments on commit 981f004

Please sign in to comment.