remove php dependency

master
bel 2020-01-20 22:31:25 -07:00
parent afcc33b76b
commit 73efeb0acf
3 changed files with 55 additions and 31 deletions

View File

@ -1,16 +1,16 @@
FROM frolvlad/alpine-glibc:alpine-3.9_glibc-2.29
RUN apk update \
&& apk add --no-cache \
ca-certificates \
bash jq curl \
php php-sqlite3 php-pdo php-pdo_mysql php-json php-pdo_sqlite
FROM golang:1.13-alpine as certs
RUN apk update && apk add --no-cache ca-certificates
FROM busybox:glibc
RUN mkdir -p /var/log
WORKDIR /main
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
COPY . .
ENV GOPATH=""
ENV MNT="/mnt/"
ENTRYPOINT ["/bin/bash", "/main/entrypoint.sh"]
ENTRYPOINT ["/main/exec-todo-server"]
CMD []

View File

@ -1,17 +0,0 @@
#! /bin/bash
(
pushd /main/testdata/mytinytodo*
php -S 0.0.0.0:38808
kill -9 1
) &
(
until curl localhost:39909; do
sleep 1
done
pushd /main/testdata
bash ./migrate.sh 192.168.0.86:44112 localhost:39909
) &
exec /main/exec-todo-server "$@"

View File

@ -2,12 +2,14 @@ package server
import (
"fmt"
"io"
"local/router"
"local/todo-server/config"
"log"
"net/http"
"net/http/httputil"
"net/url"
"os"
"path"
"path/filepath"
)
@ -20,12 +22,16 @@ func (s *Server) Routes() error {
path: "/",
handler: s.index,
},
{
path: "/mytinytodo_lang.php",
handler: s.lang,
},
{
path: fmt.Sprintf("%s%s", router.Wildcard, router.Wildcard),
handler: s.phpProxy,
},
{
path: fmt.Sprintf("ajax.php"),
path: "/ajax.php",
handler: s.HandleAjax,
},
/*
@ -96,9 +102,43 @@ func (s *Server) Routes() error {
return nil
}
func (s *Server) lang(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, `
mytinytodo.lang.init({
confirmDelete: "Are you sure you want to delete the task?",
confirmLeave: "There can be unsaved data. Do you really want to leave?",
actionNoteSave: "save",
actionNoteCancel: "cancel",
error: "Some error occurred (click for details)",
denied: "Access denied",
invalidpass: "Wrong password",
tagfilter: "Tag:",
addList: "Create new list",
addListDefault: "Todo",
renameList: "Rename list",
deleteList: "This will delete current list with all tasks in it.\nAre you sure?",
clearCompleted: "This will delete all completed tasks in the list.\nAre you sure?",
settingsSaved: "Settings saved. Reloading...",
daysMin: ["Su","Mo","Tu","We","Th","Fr","Sa"],
daysLong: ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],
monthsLong: ["January","February","March","April","May","June","July","August","September","October","November","December"],
tags: "Tags",
tasks: "Tasks",
f_past: "Overdue",
f_today: "Today and tomorrow",
f_soon: "Soon"
});
`)
}
func (s *Server) index(w http.ResponseWriter, r *http.Request) {
r.URL.Path = "/index.php"
http.Redirect(w, r, r.URL.String(), http.StatusSeeOther)
f, err := os.Open(path.Join(config.Root, "index.html"))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
defer f.Close()
io.Copy(w, f)
}
func (s *Server) phpProxy(w http.ResponseWriter, r *http.Request) {
@ -110,10 +150,11 @@ func (s *Server) phpProxy(w http.ResponseWriter, r *http.Request) {
}
url, err := url.Parse(config.MyTinyTodo)
if err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
} else {
proxy := httputil.NewSingleHostReverseProxy(url)
proxy.ServeHTTP(w, r)
log.Println("proxying", url.String(), r.URL.Path)
//proxy := httputil.NewSingleHostReverseProxy(url)
//proxy.ServeHTTP(w, r)
}
}