Skip to content

Commit d5464e8

Browse files
author
Pablo Colturi
committed
deploy to fly - app not working
1 parent d2e857f commit d5464e8

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

Dockerfile

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
# This file is used to build a Docker image that will run the scraper
21
FROM node:20.3.1-slim
32

4-
# Install the latest version of Chromium
53
FROM mcr.microsoft.com/playwright:focal
64

7-
# Install dumb-init to handle signals from Docker
5+
# Install dumb-init to gracefully handle stopping the container
86
RUN apt update && apt install dumb-init
97

108
# Set the working directory in the Docker container to /scraper
@@ -13,14 +11,15 @@ WORKDIR /scraper
1311
# Create a new user named 'node' and create a home directory for the user
1412
RUN useradd -m node
1513

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
1715
# Change the owner and group of the copied files to 'node'
1816
COPY --chown=node:node . .
1917

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
2221

23-
# Set the user (and group) that will run subsequent commands in the Docker container to 'node'
22+
# Set the user (and group)
2423
USER node:node
2524

2625
# Runs "/usr/bin/dumb-init -- /my/script --with --args"

fly.toml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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"]

readme.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@ The scraping process returns for each repository found the following data:
1919

2020
Run `npm install`
2121

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:
2325
```
2426
MONGO_URL = 'mongodb+srv://fullstack:[email protected]/repos?retryWrites=true&w=majority'
2527
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'`
2732

2833
## Dependencies
2934

@@ -61,6 +66,9 @@ Docker best practices:
6166
Check secrets:
6267
`fly secrets list`
6368

69+
Deploy to Fly
70+
`fly deploy`
71+
6472
## References
6573

6674
- The scraping part the project is based on [this tutorial](https://blog.apify.com/how-to-scrape-the-web-with-playwright-ece1ced75f73/) from Apify.

0 commit comments

Comments
 (0)