File tree 3 files changed +33
-9
lines changed
3 files changed +33
-9
lines changed Original file line number Diff line number Diff line change 1
- # This file is used to build a Docker image that will run the scraper
2
1
FROM node:20.3.1-slim
3
2
4
- # Install the latest version of Chromium
5
3
FROM mcr.microsoft.com/playwright:focal
6
4
7
- # Install dumb-init to handle signals from Docker
5
+ # Install dumb-init to gracefully handle stopping the container
8
6
RUN apt update && apt install dumb-init
9
7
10
8
# Set the working directory in the Docker container to /scraper
@@ -13,14 +11,15 @@ WORKDIR /scraper
13
11
# Create a new user named 'node' and create a home directory for the user
14
12
RUN useradd -m node
15
13
16
- # Copy all files from the current directory on the host to the current directory in the Docker container
14
+ # Copy all from current directory to /scraper directory in the container
17
15
# Change the owner and group of the copied files to 'node'
18
16
COPY --chown=node:node . .
19
17
20
- # Install the project dependencies using npm ci
21
- RUN npm ci
18
+ # Install dependencies without updating versions and package-lock.json
19
+ # Install only production dependencies
20
+ RUN npm ci --only=production
22
21
23
- # Set the user (and group) that will run subsequent commands in the Docker container to 'node'
22
+ # Set the user (and group)
24
23
USER node:node
25
24
26
25
# Runs "/usr/bin/dumb-init -- /my/script --with --args"
Original file line number Diff line number Diff line change
1
+ # fly.toml app configuration file generated for github-playright on 2023-11-14T16:32:57+01:00
2
+ #
3
+ # See https://fly.io/docs/reference/configuration/ for information about how to use this file.
4
+ #
5
+
6
+ app = " github-playright"
7
+ primary_region = " otp"
8
+
9
+ [build ]
10
+
11
+ [http_service ]
12
+ internal_port = 3000
13
+ force_https = true
14
+ auto_stop_machines = true
15
+ auto_start_machines = true
16
+ min_machines_running = 0
17
+ processes = [" app" ]
Original file line number Diff line number Diff line change @@ -19,11 +19,16 @@ The scraping process returns for each repository found the following data:
19
19
20
20
Run ` npm install `
21
21
22
- In the root folder create ` .env ` file with following keys:
22
+ ##### Configure secret/environment variables
23
+
24
+ - In the root folder create ` .env ` file with following keys:
23
25
```
24
26
MONGO_URL = 'mongodb+srv://fullstack:[email protected] /repos?retryWrites=true&w=majority'
25
27
REDIS_URL = 'redis://default:REDIS_DEFAULTUSER_PASSWORD@redis-12236.c300.eu-central-1-1.ec2.cloud.redislabs.com:12236'
26
- ```
28
+ ```
29
+ - Set sensitive data as Fly.io secrets with commands:
30
+ ` fly secrets set MONGO_URL='mongodb+srv://fullstack:[email protected] /repos?retryWrites=true&w=majority' `
31
+ ` fly secrets set REDIS_URL='redis://default:MONGODB_DEFAULTUSER_PASSWORD@redis-12236.c300.eu-central-1-1.ec2.cloud.redislabs.com:12236' `
27
32
28
33
## Dependencies
29
34
@@ -61,6 +66,9 @@ Docker best practices:
61
66
Check secrets:
62
67
` fly secrets list `
63
68
69
+ Deploy to Fly
70
+ ` fly deploy `
71
+
64
72
## References
65
73
66
74
- The scraping part the project is based on [ this tutorial] ( https://blog.apify.com/how-to-scrape-the-web-with-playwright-ece1ced75f73/ ) from Apify.
You can’t perform that action at this time.
0 commit comments