Skip to content

Commit d7d3e46

Browse files
nginx, compose, certs
1 parent 87ecc1a commit d7d3e46

File tree

7 files changed

+43
-43
lines changed

7 files changed

+43
-43
lines changed

.github/workflows/build-then-store.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ jobs:
3636

3737
- name: Build
3838
run: |
39-
docker compose --profile prod build
40-
docker compose --profile prod push
39+
docker compose build
40+
docker compose push

.github/workflows/push-then-deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ jobs:
2727
script: |
2828
cd /opt/app
2929
docker-compose down --remove-orphans
30-
docker-compose --profile prod pull
31-
docker-compose --profile prod up -d
30+
docker-compose pull
31+
docker-compose up -d

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
playgrounds/
55
.vscode/settings.json
66
.venv/
7+
cert.pem
8+
private.key

docker-compose.yml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
profiles: [test]
55
depends_on: [mongo, redis]
66
container_name: feedfarer-test
7-
restart: no
7+
restart: "no"
88
build:
99
context: .
1010
dockerfile: Dockerfile-test
@@ -19,12 +19,13 @@ services:
1919
- TEST=1
2020

2121
app:
22-
profiles: [prod]
2322
depends_on: [mongo, redis]
2423
image: ghcr.io/why-not-try-calmer/feedo:latest
25-
restart: on-failure
26-
build: .
27-
command: ./feefarer-exe
24+
restart: "on-failure"
25+
build:
26+
context: .
27+
dockerfile: Dockerfile
28+
command: ./feedfarer-exe
2829
environment:
2930
API_KEY: ${API_KEY}
3031
TELEGRAM_TOKEN: ${TELEGRAM_TOKEN}
@@ -37,20 +38,17 @@ services:
3738

3839
mongo:
3940
image: mongo:5.0 # `auth` doesn't work with 6.0 and beyond!
40-
restart: on-failure
41+
restart: "on-failure"
4142
environment:
4243
- MONGO_INITDB_ROOT_USERNAME
4344
- MONGO_INITDB_ROOT_PASSWORD
4445
volumes:
4546
- mongo-data:/data/db
46-
ports:
47-
- 27017:27017
48-
47+
4948
nginx:
50-
profiles: [prod]
5149
depends_on: [app]
5250
image: nginx:latest
53-
restart: on-failure
51+
restart: "on-failure"
5452
volumes:
5553
- ./nginx.conf:/etc/nginx/nginx.conf:ro
5654
- ./private.key:/etc/nginx/private.key:ro
@@ -61,12 +59,11 @@ services:
6159

6260
redis:
6361
image: redis:latest
64-
expose: [6379]
65-
restart: on-failure
62+
restart: "on-failure"
6663
command: redis-server --maxmemory 250mb --maxmemory-policy volatile-lfu
6764
volumes:
6865
- redis-data:/data/redis-store
6966

7067
volumes:
7168
mongo-data:
72-
redis-data:
69+
redis-data:

nginx.conf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ http {
1919
add_header Strict-Transport-Security "max-age=31536000" always;
2020

2121
location /webhook {
22-
proxy_pass http://feedo:8000;
22+
proxy_pass http://app:8000;
23+
}
24+
25+
location /digests {
26+
proxy_pass http://app:8000;
2327
}
2428
}
2529
}

scripts/setWebhook.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/bash
22
source .env
3-
4-
openssl req -newkey rsa:2048 -sha256 -nodes -keyout private.key -x509 -days 365 -out cert.pem -subj "/C=US/ST=Bern/L=Bern/O=MyOwn/CN=$SERVER_URL"
5-
6-
curl -F "url=https://feedo.cloudns.ph/webhook/$TELEGRAM_TOKEN" https://api.telegram.org/bot$TELEGRAM_TOKEN/setWebhook -F "certificate=@/opt/app/cert.pem"
7-
3+
openssl req -newkey rsa:2048 -sha256 -nodes -keyout private.key -x509 -days 365 -out cert.pem -subj "/C=US/ST=Bern/L=Bern/O=MyOwn/CN=$DOMAIN_NAME"
4+
curl -F "url=https://feedo.cloudns.ph/webhook/bot$TELEGRAM_TOKEN" https://api.telegram.org/bot$TELEGRAM_TOKEN/setWebhook -F "certificate=@/opt/app/cert.pem"

src/Server.hs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -169,21 +169,21 @@ startApp = do
169169
-- no longer using registerWebhook as it needs updating to use TLS certification
170170
-- registerWebhook config
171171
runApp config initStart
172-
finds_ssl_keys <- (&&) <$> doesFileExist sslCert <*> doesFileExist sslKey
173-
if finds_ssl_keys
174-
then do
175-
print $ "Server (HTTPS) now listening to port " <> show port
176-
runTLS tlsOpts (warpOpts port) . withServer $ config
177-
else do
178-
dir <- getCurrentDirectory
179-
print $ "WARNING: Missing SSL keys from " <> dir
180-
print $
181-
"TLS will need to rely on gateway (if any). \
182-
\ Server (PLAIN HTTP) now listening to port "
183-
<> show port
184-
run port $ withServer config
185-
where
186-
warpOpts p
187-
| p == 80 = setPort 443 defaultSettings
188-
| otherwise = setPort p defaultSettings
189-
tlsOpts = tlsSettings sslCert sslKey
172+
-- finds_ssl_keys <- (&&) <$> doesFileExist sslCert <*> doesFileExist sslKey
173+
-- if finds_ssl_keys
174+
-- then do
175+
-- print $ "Server (HTTPS) now listening to port " <> show port
176+
-- runTLS tlsOpts (warpOpts port) . withServer $ config
177+
-- else do
178+
-- dir <- getCurrentDirectory
179+
-- print $ "WARNING: Missing SSL keys from " <> dir
180+
-- print $
181+
-- "TLS will need to rely on gateway (if any). \
182+
-- \ Server (PLAIN HTTP) now listening to port "
183+
-- <> show port
184+
run port $ withServer config
185+
-- where
186+
-- warpOpts p
187+
-- | p == 80 = setPort 443 defaultSettings
188+
-- | otherwise = setPort p defaultSettings
189+
-- tlsOpts = tlsSettings sslCert sslKey

0 commit comments

Comments
 (0)