diff --git a/Dockerfile b/Dockerfile index c3c76e9..78347e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ -FROM golang:latest as builder +FROM golang:alpine as builder +# RUN apt install -y git make +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && apk update && apk --no-cache add make git LABEL anther="cjun" WORKDIR /tinyurl COPY . /tinyurl @@ -9,10 +11,12 @@ RUN make build FROM alpine:latest AS runner # 设置alpine 时间为上海时间 -RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && apk update && apk --no-cache add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo "Asia/Shanghai" > /etc/timezone \ && apk del tzdata WORKDIR /app COPY --from=builder /tinyurl/bin/tinyurl /app/tinyurl +COPY --from=builder /tinyurl/dist/ /app/dist/ +COPY --from=builder /tinyurl/configs/ /app/configs/ EXPOSE 2830 CMD ["./tinyurl"] \ No newline at end of file diff --git a/dist/assets/index.6bb8942b.js b/dist/assets/index.b2aedd95.js similarity index 99% rename from dist/assets/index.6bb8942b.js rename to dist/assets/index.b2aedd95.js index 400d8bd..23f70a2 100644 --- a/dist/assets/index.6bb8942b.js +++ b/dist/assets/index.b2aedd95.js @@ -303,4 +303,4 @@ PERFORMANCE OF THIS SOFTWARE. * https://clipboardjs.com/ * * Licensed MIT © Zeno Rocha - */(function(e,t){(function(r,o){e.exports=o()})(vh,function(){return function(){var n={686:function(s,a,i){i.d(a,{default:function(){return ot}});var l=i(279),c=i.n(l),u=i(370),d=i.n(u),g=i(817),v=i.n(g);function A(I){try{return document.execCommand(I)}catch{return!1}}var $=function(L){var P=v()(L);return A("cut"),P},C=$;function E(I){var L=document.documentElement.getAttribute("dir")==="rtl",P=document.createElement("textarea");P.style.fontSize="12pt",P.style.border="0",P.style.padding="0",P.style.margin="0",P.style.position="absolute",P.style[L?"right":"left"]="-9999px";var D=window.pageYOffset||document.documentElement.scrollTop;return P.style.top="".concat(D,"px"),P.setAttribute("readonly",""),P.value=I,P}var K=function(L){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},D="";if(typeof L=="string"){var N=E(L);P.container.appendChild(N),D=v()(N),A("copy"),N.remove()}else D=v()(L),A("copy");return D},q=K;function V(I){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?V=function(P){return typeof P}:V=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},V(I)}var pe=function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},P=L.action,D=P===void 0?"copy":P,N=L.container,Q=L.target,ce=L.text;if(D!=="copy"&&D!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(Q!==void 0)if(Q&&V(Q)==="object"&&Q.nodeType===1){if(D==="copy"&&Q.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(D==="cut"&&(Q.hasAttribute("readonly")||Q.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(ce)return q(ce,{container:N});if(Q)return D==="cut"?C(Q):q(Q,{container:N})},Ee=pe;function W(I){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?W=function(P){return typeof P}:W=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},W(I)}function ae(I,L){if(!(I instanceof L))throw new TypeError("Cannot call a class as a function")}function re(I,L){for(var P=0;P0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof N.action=="function"?N.action:this.defaultAction,this.target=typeof N.target=="function"?N.target:this.defaultTarget,this.text=typeof N.text=="function"?N.text:this.defaultText,this.container=W(N.container)==="object"?N.container:document.body}},{key:"listenClick",value:function(N){var Q=this;this.listener=d()(N,"click",function(ce){return Q.onClick(ce)})}},{key:"onClick",value:function(N){var Q=N.delegateTarget||N.currentTarget,ce=this.action(Q)||"copy",Ke=Ee({action:ce,container:this.container,target:this.target(Q),text:this.text(Q)});this.emit(Ke?"success":"error",{action:ce,text:Ke,trigger:Q,clearSelection:function(){Q&&Q.focus(),document.activeElement.blur(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(N){return te("action",N)}},{key:"defaultTarget",value:function(N){var Q=te("target",N);if(Q)return document.querySelector(Q)}},{key:"defaultText",value:function(N){return te("text",N)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(N){var Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return q(N,Q)}},{key:"cut",value:function(N){return C(N)}},{key:"isSupported",value:function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],Q=typeof N=="string"?[N]:N,ce=!!document.queryCommandSupported;return Q.forEach(function(Ke){ce=ce&&!!document.queryCommandSupported(Ke)}),ce}}]),P}(c()),ot=Re},828:function(s){var a=9;if(typeof Element!="undefined"&&!Element.prototype.matches){var i=Element.prototype;i.matches=i.matchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector||i.webkitMatchesSelector}function l(c,u){for(;c&&c.nodeType!==a;){if(typeof c.matches=="function"&&c.matches(u))return c;c=c.parentNode}}s.exports=l},438:function(s,a,i){var l=i(828);function c(g,v,A,$,C){var E=d.apply(this,arguments);return g.addEventListener(A,E,C),{destroy:function(){g.removeEventListener(A,E,C)}}}function u(g,v,A,$,C){return typeof g.addEventListener=="function"?c.apply(null,arguments):typeof A=="function"?c.bind(null,document).apply(null,arguments):(typeof g=="string"&&(g=document.querySelectorAll(g)),Array.prototype.map.call(g,function(E){return c(E,v,A,$,C)}))}function d(g,v,A,$){return function(C){C.delegateTarget=l(C.target,v),C.delegateTarget&&$.call(g,C)}}s.exports=u},879:function(s,a){a.node=function(i){return i!==void 0&&i instanceof HTMLElement&&i.nodeType===1},a.nodeList=function(i){var l=Object.prototype.toString.call(i);return i!==void 0&&(l==="[object NodeList]"||l==="[object HTMLCollection]")&&"length"in i&&(i.length===0||a.node(i[0]))},a.string=function(i){return typeof i=="string"||i instanceof String},a.fn=function(i){var l=Object.prototype.toString.call(i);return l==="[object Function]"}},370:function(s,a,i){var l=i(879),c=i(438);function u(A,$,C){if(!A&&!$&&!C)throw new Error("Missing required arguments");if(!l.string($))throw new TypeError("Second argument must be a String");if(!l.fn(C))throw new TypeError("Third argument must be a Function");if(l.node(A))return d(A,$,C);if(l.nodeList(A))return g(A,$,C);if(l.string(A))return v(A,$,C);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function d(A,$,C){return A.addEventListener($,C),{destroy:function(){A.removeEventListener($,C)}}}function g(A,$,C){return Array.prototype.forEach.call(A,function(E){E.addEventListener($,C)}),{destroy:function(){Array.prototype.forEach.call(A,function(E){E.removeEventListener($,C)})}}}function v(A,$,C){return c(document.body,A,$,C)}s.exports=u},817:function(s){function a(i){var l;if(i.nodeName==="SELECT")i.focus(),l=i.value;else if(i.nodeName==="INPUT"||i.nodeName==="TEXTAREA"){var c=i.hasAttribute("readonly");c||i.setAttribute("readonly",""),i.select(),i.setSelectionRange(0,i.value.length),c||i.removeAttribute("readonly"),l=i.value}else{i.hasAttribute("contenteditable")&&i.focus();var u=window.getSelection(),d=document.createRange();d.selectNodeContents(i),u.removeAllRanges(),u.addRange(d),l=u.toString()}return l}s.exports=a},279:function(s){function a(){}a.prototype={on:function(i,l,c){var u=this.e||(this.e={});return(u[i]||(u[i]=[])).push({fn:l,ctx:c}),this},once:function(i,l,c){var u=this;function d(){u.off(i,d),l.apply(c,arguments)}return d._=l,this.on(i,d,c)},emit:function(i){var l=[].slice.call(arguments,1),c=((this.e||(this.e={}))[i]||[]).slice(),u=0,d=c.length;for(u;u{const t=(e==null?void 0:e.appendToBody)===void 0?!0:e.appendToBody;return{toClipboard(n,r){return new Promise((o,s)=>{const a=document.createElement("button"),i=new c0(a,{text:()=>n,action:()=>"copy",container:r!==void 0?r:document.body});i.on("success",l=>{i.destroy(),o(l)}),i.on("error",l=>{i.destroy(),s(l)}),t&&document.body.appendChild(a),a.click(),t&&document.body.removeChild(a)})}}};const d0=j("div",{class:"header"},null,-1),h0={class:"middle"},p0=j("img",{src:kh,alt:"",class:"tinylogo"},null,-1),g0={key:0,class:"tinyout"},v0={class:"outstyle"},m0=["href"],b0={style:{display:"block"}},y0=j("div",{class:"padding"},null,-1),_0=j("div",{class:"footer"},[j("div",null,"Copyright \xA9 2022 \u{1F42E}\u{1F37A} All Rights Reserved.")],-1),w0={setup(e){const{toClipboard:t}=f0(),n=Ce(""),r=Ce(""),o=Ce(!1);let s=()=>{Up({method:"post",url:"http://localhost:2830/api/v1/tiny",data:{longUrl:n.value}}).then(i=>{console.log(i.data),r.value=i.data.shortUrl,o.value=!0})};const a=async i=>{Mh({title:"Success",message:"This is a success message",type:"success"});try{await t(i),console.log("Copied to clipboard")}catch(l){console.error(l)}};return(i,l)=>{const c=Kd,u=gh;return k(),H(we,null,[d0,j("div",h0,[p0,ge(c,{modelValue:n.value,"onUpdate:modelValue":l[0]||(l[0]=d=>n.value=d),onKeyup:Wc(y(s),["enter"]),class:"tinyinput",style:{"border-radius":"15px"},placeholder:"\u{1F37A} "},null,8,["modelValue","onKeyup"])]),o.value?(k(),H("div",g0,[j("div",v0,[j("a",{href:r.value,style:{"font-size":"25px",color:"black","background-color":"lightsalmon","text-decoration":"none"},target:"_blank"},Kt(r.value),9,m0),ge(u,{icon:y(Rf),onClick:l[1]||(l[1]=d=>a(r.value)),style:{border:"none","margin-left":"10px"},size:"large",circle:""},null,8,["icon"])]),j("div",b0,[ge(y(vn),{url:r.value,twitter:!0,google:!0},null,8,["url"])])])):J("",!0),y0,_0],64)}}};Jc(w0).mount("#app"); + */(function(e,t){(function(r,o){e.exports=o()})(vh,function(){return function(){var n={686:function(s,a,i){i.d(a,{default:function(){return ot}});var l=i(279),c=i.n(l),u=i(370),d=i.n(u),g=i(817),v=i.n(g);function A(I){try{return document.execCommand(I)}catch{return!1}}var $=function(L){var P=v()(L);return A("cut"),P},C=$;function E(I){var L=document.documentElement.getAttribute("dir")==="rtl",P=document.createElement("textarea");P.style.fontSize="12pt",P.style.border="0",P.style.padding="0",P.style.margin="0",P.style.position="absolute",P.style[L?"right":"left"]="-9999px";var D=window.pageYOffset||document.documentElement.scrollTop;return P.style.top="".concat(D,"px"),P.setAttribute("readonly",""),P.value=I,P}var K=function(L){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},D="";if(typeof L=="string"){var N=E(L);P.container.appendChild(N),D=v()(N),A("copy"),N.remove()}else D=v()(L),A("copy");return D},q=K;function V(I){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?V=function(P){return typeof P}:V=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},V(I)}var pe=function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},P=L.action,D=P===void 0?"copy":P,N=L.container,Q=L.target,ce=L.text;if(D!=="copy"&&D!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(Q!==void 0)if(Q&&V(Q)==="object"&&Q.nodeType===1){if(D==="copy"&&Q.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(D==="cut"&&(Q.hasAttribute("readonly")||Q.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(ce)return q(ce,{container:N});if(Q)return D==="cut"?C(Q):q(Q,{container:N})},Ee=pe;function W(I){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?W=function(P){return typeof P}:W=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},W(I)}function ae(I,L){if(!(I instanceof L))throw new TypeError("Cannot call a class as a function")}function re(I,L){for(var P=0;P0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof N.action=="function"?N.action:this.defaultAction,this.target=typeof N.target=="function"?N.target:this.defaultTarget,this.text=typeof N.text=="function"?N.text:this.defaultText,this.container=W(N.container)==="object"?N.container:document.body}},{key:"listenClick",value:function(N){var Q=this;this.listener=d()(N,"click",function(ce){return Q.onClick(ce)})}},{key:"onClick",value:function(N){var Q=N.delegateTarget||N.currentTarget,ce=this.action(Q)||"copy",Ke=Ee({action:ce,container:this.container,target:this.target(Q),text:this.text(Q)});this.emit(Ke?"success":"error",{action:ce,text:Ke,trigger:Q,clearSelection:function(){Q&&Q.focus(),document.activeElement.blur(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(N){return te("action",N)}},{key:"defaultTarget",value:function(N){var Q=te("target",N);if(Q)return document.querySelector(Q)}},{key:"defaultText",value:function(N){return te("text",N)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(N){var Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return q(N,Q)}},{key:"cut",value:function(N){return C(N)}},{key:"isSupported",value:function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],Q=typeof N=="string"?[N]:N,ce=!!document.queryCommandSupported;return Q.forEach(function(Ke){ce=ce&&!!document.queryCommandSupported(Ke)}),ce}}]),P}(c()),ot=Re},828:function(s){var a=9;if(typeof Element!="undefined"&&!Element.prototype.matches){var i=Element.prototype;i.matches=i.matchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector||i.webkitMatchesSelector}function l(c,u){for(;c&&c.nodeType!==a;){if(typeof c.matches=="function"&&c.matches(u))return c;c=c.parentNode}}s.exports=l},438:function(s,a,i){var l=i(828);function c(g,v,A,$,C){var E=d.apply(this,arguments);return g.addEventListener(A,E,C),{destroy:function(){g.removeEventListener(A,E,C)}}}function u(g,v,A,$,C){return typeof g.addEventListener=="function"?c.apply(null,arguments):typeof A=="function"?c.bind(null,document).apply(null,arguments):(typeof g=="string"&&(g=document.querySelectorAll(g)),Array.prototype.map.call(g,function(E){return c(E,v,A,$,C)}))}function d(g,v,A,$){return function(C){C.delegateTarget=l(C.target,v),C.delegateTarget&&$.call(g,C)}}s.exports=u},879:function(s,a){a.node=function(i){return i!==void 0&&i instanceof HTMLElement&&i.nodeType===1},a.nodeList=function(i){var l=Object.prototype.toString.call(i);return i!==void 0&&(l==="[object NodeList]"||l==="[object HTMLCollection]")&&"length"in i&&(i.length===0||a.node(i[0]))},a.string=function(i){return typeof i=="string"||i instanceof String},a.fn=function(i){var l=Object.prototype.toString.call(i);return l==="[object Function]"}},370:function(s,a,i){var l=i(879),c=i(438);function u(A,$,C){if(!A&&!$&&!C)throw new Error("Missing required arguments");if(!l.string($))throw new TypeError("Second argument must be a String");if(!l.fn(C))throw new TypeError("Third argument must be a Function");if(l.node(A))return d(A,$,C);if(l.nodeList(A))return g(A,$,C);if(l.string(A))return v(A,$,C);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function d(A,$,C){return A.addEventListener($,C),{destroy:function(){A.removeEventListener($,C)}}}function g(A,$,C){return Array.prototype.forEach.call(A,function(E){E.addEventListener($,C)}),{destroy:function(){Array.prototype.forEach.call(A,function(E){E.removeEventListener($,C)})}}}function v(A,$,C){return c(document.body,A,$,C)}s.exports=u},817:function(s){function a(i){var l;if(i.nodeName==="SELECT")i.focus(),l=i.value;else if(i.nodeName==="INPUT"||i.nodeName==="TEXTAREA"){var c=i.hasAttribute("readonly");c||i.setAttribute("readonly",""),i.select(),i.setSelectionRange(0,i.value.length),c||i.removeAttribute("readonly"),l=i.value}else{i.hasAttribute("contenteditable")&&i.focus();var u=window.getSelection(),d=document.createRange();d.selectNodeContents(i),u.removeAllRanges(),u.addRange(d),l=u.toString()}return l}s.exports=a},279:function(s){function a(){}a.prototype={on:function(i,l,c){var u=this.e||(this.e={});return(u[i]||(u[i]=[])).push({fn:l,ctx:c}),this},once:function(i,l,c){var u=this;function d(){u.off(i,d),l.apply(c,arguments)}return d._=l,this.on(i,d,c)},emit:function(i){var l=[].slice.call(arguments,1),c=((this.e||(this.e={}))[i]||[]).slice(),u=0,d=c.length;for(u;u{const t=(e==null?void 0:e.appendToBody)===void 0?!0:e.appendToBody;return{toClipboard(n,r){return new Promise((o,s)=>{const a=document.createElement("button"),i=new c0(a,{text:()=>n,action:()=>"copy",container:r!==void 0?r:document.body});i.on("success",l=>{i.destroy(),o(l)}),i.on("error",l=>{i.destroy(),s(l)}),t&&document.body.appendChild(a),a.click(),t&&document.body.removeChild(a)})}}};const d0=j("div",{class:"header"},null,-1),h0={class:"middle"},p0=j("img",{src:kh,alt:"",class:"tinylogo"},null,-1),g0={key:0,class:"tinyout"},v0={class:"outstyle"},m0=["href"],b0={style:{display:"block"}},y0=j("div",{class:"padding"},null,-1),_0=j("div",{class:"footer"},[j("div",null,"Copyright \xA9 2022 \u{1F42E}\u{1F37A} All Rights Reserved.")],-1),w0={setup(e){const{toClipboard:t}=f0(),n=Ce(""),r=Ce(""),o=Ce(!1);let s=()=>{Up({method:"post",url:"/api/v1/tiny",data:{longUrl:n.value}}).then(i=>{console.log(i.data),r.value=i.data.shortUrl,o.value=!0})};const a=async i=>{Mh({title:"Success",message:"This is a success message",type:"success"});try{await t(i),console.log("Copied to clipboard")}catch(l){console.error(l)}};return(i,l)=>{const c=Kd,u=gh;return k(),H(we,null,[d0,j("div",h0,[p0,ge(c,{modelValue:n.value,"onUpdate:modelValue":l[0]||(l[0]=d=>n.value=d),onKeyup:Wc(y(s),["enter"]),class:"tinyinput",style:{"border-radius":"15px"},placeholder:"\u{1F37A} "},null,8,["modelValue","onKeyup"])]),o.value?(k(),H("div",g0,[j("div",v0,[j("a",{href:r.value,style:{"font-size":"25px",color:"black","background-color":"lightsalmon","text-decoration":"none"},target:"_blank"},Kt(r.value),9,m0),ge(u,{icon:y(Rf),onClick:l[1]||(l[1]=d=>a(r.value)),style:{border:"none","margin-left":"10px"},size:"large",circle:""},null,8,["icon"])]),j("div",b0,[ge(y(vn),{url:r.value,twitter:!0,google:!0},null,8,["url"])])])):J("",!0),y0,_0],64)}}};Jc(w0).mount("#app"); diff --git a/dist/index.html b/dist/index.html index 8fc0be6..2a2c2a9 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5,7 +5,7 @@ TinyUrl - + diff --git a/makefile b/makefile index 308c8eb..dd7712a 100644 --- a/makefile +++ b/makefile @@ -20,6 +20,13 @@ LDFlags=" \ build: mkdir -p bin/ && go build -ldflags $(LDFlags) -o ./bin/ ./... +.PHONY:buildx +buildx: + docker run --privileged --rm tonistiigi/binfmt --install all + docker buildx create --use --name xbuilder + docker buildx inspect xbuilder --bootstrap + docker buildx build --platform linux/amd64,linux/arm64 -t mirrors2/tinyurl:latest . --push + .PHONY: clean # clean clean: