docker image
This commit is contained in:
parent
adcb02180d
commit
1e2f124e65
3 changed files with 46 additions and 0 deletions
|
@ -6,6 +6,10 @@ This repo has a simple sync script with a few features:
|
|||
- after install commands
|
||||
- deploy script
|
||||
|
||||
## Deployment
|
||||
To import the dotfiles run:
|
||||
`curl --proto '=https' --tlsv1.2 -sSf https://git.faulty.nl/didier/dotfiles/-/raw/main/lib/deploy.sh | sh`
|
||||
|
||||
## Notes
|
||||
- `gpackage.list`
|
||||
This is a list with packages only installed if the `-g` or `--graphical` flag is used.
|
12
lib/Dockerfile
Normal file
12
lib/Dockerfile
Normal file
|
@ -0,0 +1,12 @@
|
|||
FROM python:3.10-alpine
|
||||
|
||||
RUN apk add git
|
||||
|
||||
COPY . /app
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# if no remote then add remote or otherwrite
|
||||
RUN git remote get-url origin || git remote add origin https://git.faulty.nl/didier/dotfiles && git remote set-url origin https://git.faulty.nl/didier/dotfiles
|
||||
|
||||
ENTRYPOINT ["python3", "/app/lib/docker.py"]
|
30
lib/docker.py
Normal file
30
lib/docker.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
# any HTTP request returns the contents of: ./lib/deploy.sh
|
||||
# If the deploy script is older then a day, do a git pull
|
||||
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
import subprocess
|
||||
import os
|
||||
import time
|
||||
|
||||
class handler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type','text/plain')
|
||||
self.end_headers()
|
||||
if (time.time() - os.path.getmtime('./lib/deploy.sh') > 86400):
|
||||
subprocess.call(['git', 'pull'])
|
||||
with open('./lib/deploy.sh') as f:
|
||||
self.wfile.write(bytes(f.read(), 'utf-8'))
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
server = HTTPServer(('', 80), handler)
|
||||
print('started httpserver...')
|
||||
server.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
print('^C received, shutting down the web server')
|
||||
server.socket.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in a new issue