prepare for production

This commit is contained in:
dreamer 2020-10-12 11:17:24 +02:00
parent e6fa005b1a
commit f055cb3002
6 changed files with 38 additions and 12 deletions

View File

@ -4,4 +4,4 @@ RUN docker-luarocks-install busted
WORKDIR /srv/lapis
CMD lapis server
CMD lapis server $ENVIRONMENT

View File

@ -1,19 +1,18 @@
local config = require("lapis.config")
config("development", {
config({"development", "production"}, {
host = "tracks.intergalactic.fm",
greeting = "dingen",
postgres = {
host = "postgres",
user = "postgres",
password = "the_password",
-- password = "the_password",
database = "postgres"
}
})
config("test", {
config("production", {
greeting = "different greeting",
postgres = {
host = "postgres",
user = "postgres",
password = "the_password",
database = "test"
password = os.getenv('POSTGRES_PASSWORD')
}
})

View File

@ -8,6 +8,7 @@ function Splhandler(self)
-- TODO: add auth-token
-- secret=STATION_SECRET_#&
-- artist_name=%a&
-- track_name=%t&
-- release_name=%T
@ -30,10 +31,19 @@ function Splhandler(self)
local station = models.Stations:find({ station = station_id })
if not station then
print("unknown station: " .. station_id)
return
else
print("This is: " .. station["name"])
end
local station_secret = os.getenv('STATION_SECRET_'..station_id) or nil
local request_secret = self.params.secret
if station_secret then
if station_secret ~= request_secret then
return
end
end
local artist = nil
local artist_name = self.params.artist_name -- mandatory
@ -52,6 +62,11 @@ function Splhandler(self)
local airtime = self.params.time -- mandatory
local airdate = self.params.date -- mandatory
-- check mandatory fields
if not artist_name or track_name or airtime or airdate then
return
end
-- we have to split the `hr:min:sec` and `month/day/year` strings from SPL
local function Split(s, delimiter)
local result = {}

View File

@ -58,9 +58,9 @@ function Stationhandler(self)
return { json = self.airtimes }
end
for i, item in ipairs(self.airtimes) do
print(to_json(item))
end
-- for i, item in ipairs(self.airtimes) do
-- print(to_json(item))
-- end
return { render = "station" }

View File

@ -3,6 +3,10 @@ error_log stderr notice;
daemon off;
pid logs/nginx.pid;
env POSTGRES_PASSWORD;
env STATION_SECRET_1;
env STATION_SECRET_2;
env STATION_SECRET_3;
events {
worker_connections 1024;

View File

@ -1,6 +1,12 @@
version: "3"
services:
previouslyonifm:
environment:
- ENVIRONMENT
- POSTGRES_PASSWORD
- STATION_SECRET_1
- STATION_SECRET_2
- STATION_SECRET_3
build: .
volumes:
- ./code:/srv/lapis
@ -10,4 +16,6 @@ services:
postgres:
image: postgres:12-alpine
environment:
POSTGRES_PASSWORD: the_password
- POSTGRES_PASSWORD
volumes:
- /opt/trackdb:/var/lib/postgresql/data