Docker
This commit is contained in:
parent
b82118f8b2
commit
9aafc9b37c
18
Dockerfile
Normal file
18
Dockerfile
Normal file
@ -0,0 +1,18 @@
|
||||
FROM python:3.9-slim
|
||||
RUN apt-get update && apt-get install -y \
|
||||
sqlite3 \
|
||||
libsqlite3-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
COPY requirements.txt /app/
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
COPY src /app/src
|
||||
COPY src/manage_users.py /app/src/
|
||||
RUN python /app/src/manage_users.py init
|
||||
ENV FLASK_APP=src/app.py
|
||||
ENV FLASK_RUN_HOST=0.0.0.0
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
CMD ["flask", "run"]
|
19
README.md
19
README.md
@ -16,7 +16,7 @@ git clone https://git.confest.im/boyan_k/shortn
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
## Usage
|
||||
## Usage (no docker)
|
||||
```bash
|
||||
python manage_users.py init # to create the database
|
||||
python manage_users.py add # to add a user
|
||||
@ -31,9 +31,24 @@ python manage_users.py remove --username <username> # to remove a user
|
||||
python app.py
|
||||
```
|
||||
|
||||
## Usage (docker)
|
||||
This will init the database and create a user with the username `admin` and password `admin`.
|
||||
```bash
|
||||
docker compose up -d # remove -d for foreground
|
||||
```
|
||||
|
||||
### Users
|
||||
```bash
|
||||
sudo docker exec -it shortn python src/manage_users.py add
|
||||
sudo docker exec -it shortn python src/manage_users.py list
|
||||
sudo docker exec -it shortn python src/manage_users.py remove --username <username>
|
||||
```
|
||||
|
||||
> [!NOTE] The database is **ephemeral** and will be lost when the container is removed. That is intentional.
|
||||
|
||||
## TODOs
|
||||
- [x] basic UI (to add links)
|
||||
- [x] basic auth for UI
|
||||
- [x] sqlite3 to store links
|
||||
- [x] responsive? (sorta)
|
||||
- [ ] dockerize
|
||||
- [x] dockerize
|
||||
|
13
docker-compose.yml
Normal file
13
docker-compose.yml
Normal file
@ -0,0 +1,13 @@
|
||||
services:
|
||||
shortn:
|
||||
build:
|
||||
context: .
|
||||
container_name: shortn
|
||||
ports:
|
||||
- "5000:5000"
|
||||
volumes:
|
||||
- ./src:/app/src
|
||||
environment:
|
||||
FLASK_APP: src/app.py
|
||||
FLASK_RUN_HOST: 0.0.0.0
|
||||
command: sh -c "python /app/src/manage_users.py init && flask run"
|
7
requirements.txt
Normal file
7
requirements.txt
Normal file
@ -0,0 +1,7 @@
|
||||
blinker==1.9.0
|
||||
click==8.1.7
|
||||
Flask==3.1.0
|
||||
itsdangerous==2.2.0
|
||||
Jinja2==3.1.4
|
||||
MarkupSafe==3.0.2
|
||||
Werkzeug==3.1.3
|
@ -95,4 +95,8 @@ def main():
|
||||
print("Invalid command. Use --help for usage information.")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
try:
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user