NOT DONE YET - allow containerization
a bunch was restructured to make it amenable to docker. it works fine, except when writing to the db. trying to log in (thus creating a session) will have Lapis throw "attempt to write a readonly database"
This commit is contained in:
parent
af20b626d5
commit
0d7ed52679
7
.dockerignore
Normal file
7
.dockerignore
Normal file
@ -0,0 +1,7 @@
|
||||
logs/
|
||||
nginx.conf.compiled
|
||||
.vscode/
|
||||
.local/
|
||||
data/db/*
|
||||
secrets
|
||||
sass
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -2,9 +2,7 @@ logs/
|
||||
nginx.conf.compiled
|
||||
.vscode/
|
||||
.local/
|
||||
data/db/*
|
||||
secrets/secrets.lua
|
||||
data/static/avatars/*
|
||||
!data/static/avatars/default.webp
|
||||
data/db/*
|
||||
secrets.lua
|
||||
|
||||
.first_launch.*
|
||||
|
20
Dockerfile
Normal file
20
Dockerfile
Normal file
@ -0,0 +1,20 @@
|
||||
# HOW TO:
|
||||
#
|
||||
# docker build -t porom:latest .
|
||||
#
|
||||
# Then run the container:
|
||||
#
|
||||
# docker compose up
|
||||
#
|
||||
# NOTE: not working yet. i get an error that the db is read-only :(
|
||||
#
|
||||
FROM openresty/openresty:alpine-fat
|
||||
|
||||
RUN apk add --no-cache git make gcc g++ musl-dev libffi-dev openssl-dev sqlite-dev libsodium libsodium-dev imagemagick-dev openssl
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN eval "$(luarocks --lua-version=5.1 path)"
|
||||
RUN luarocks --lua-version=5.1 build --only-deps
|
||||
EXPOSE 8080
|
||||
RUN chmod +x /app/start.sh
|
||||
ENTRYPOINT ["/app/start.sh", "production"]
|
@ -1,5 +1,5 @@
|
||||
local config = require("lapis.config")
|
||||
local secrets = require("secrets")
|
||||
local secrets = require("secrets.secrets")
|
||||
|
||||
config({"development", "production"}, {
|
||||
port = 8080,
|
||||
|
10
docker-compose.yml
Normal file
10
docker-compose.yml
Normal file
@ -0,0 +1,10 @@
|
||||
services:
|
||||
porom:
|
||||
build:
|
||||
context: .
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ./data/static:/app/data/static
|
||||
- ./data/db:/app/data/db
|
||||
- ./secrets:/app/secrets
|
10
start.sh
10
start.sh
@ -1,12 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
start() {
|
||||
lapis serve
|
||||
}
|
||||
|
||||
first_launch() {
|
||||
echo "Setting up for the first time"
|
||||
touch ".first_launch.$LAPIS_ENVIRONMENT"
|
||||
mkdir -p secrets
|
||||
local SECRET
|
||||
SECRET="$(openssl rand -hex 32)"
|
||||
echo "return { key = \"${SECRET}\",}" > secrets/secrets.lua
|
||||
touch "secrets/.touched.$LAPIS_ENVIRONMENT"
|
||||
mkdir -p data/db
|
||||
luajit schema.lua
|
||||
lapis migrate
|
||||
@ -22,7 +28,7 @@ fi
|
||||
|
||||
echo "Starting in $LAPIS_ENVIRONMENT"
|
||||
|
||||
if ! [ -f ".first_launch.$LAPIS_ENVIRONMENT" ]; then
|
||||
if ! [ -f ".touched.$LAPIS_ENVIRONMENT" ]; then
|
||||
first_launch
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user