forked from Botanical/BotanJS
Added docker windows container for dev
This commit is contained in:
parent
7419c1c869
commit
01dca50e2e
13
.dockerignore
Normal file
13
.dockerignore
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
.dockerignore
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
*~
|
||||||
|
*.swp
|
||||||
|
*.pyc
|
||||||
|
Dockerfile
|
||||||
|
k8s.yaml
|
||||||
|
windows/*
|
||||||
|
__pycache__
|
||||||
|
cache/*
|
||||||
|
logs/*
|
||||||
|
env/*
|
26
README.md
26
README.md
@ -1,8 +1,12 @@
|
|||||||
# BotanJS
|
# BotanJS
|
||||||
A working concept of Js/Css framework for web browsers
|
A working concept of Js/Css framework for web browsers
|
||||||
|
|
||||||
### Showcase
|
### Disclaimer
|
||||||
- Pending
|
- This is a working concept. So it works on me. And may have a bunch of useless dependency. Use at your own risks!
|
||||||
|
|
||||||
|
### Try it - Docker for windows (using windows container with nanoserver)
|
||||||
|
- docker -f windows/docker-compose.yml build
|
||||||
|
- docker -f windows/docker-compose.yml up
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
- Compressable by Closure Compiler (Advanced Compression)
|
- Compressable by Closure Compiler (Advanced Compression)
|
||||||
@ -10,29 +14,13 @@ A working concept of Js/Css framework for web browsers
|
|||||||
- Everything is merged into one file for that page
|
- Everything is merged into one file for that page
|
||||||
- css class inheritance
|
- css class inheritance
|
||||||
|
|
||||||
### Disclaimer
|
|
||||||
- This is a working concept. So it works on me. And may have a bunch of useless dependency. Use at your own risks!
|
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
- Will be added later
|
- Will be added later
|
||||||
|
|
||||||
### Prerequisties
|
### Prerequisties
|
||||||
- python3
|
- python3
|
||||||
- virtualenv
|
- virtualenv ( optional )
|
||||||
|
|
||||||
#### For Service.WebAPI
|
|
||||||
- pip install Flask
|
- pip install Flask
|
||||||
- pip install Celery
|
- pip install Celery
|
||||||
- pip install redis
|
- pip install redis
|
||||||
- pip install compressinja
|
- pip install compressinja
|
||||||
|
|
||||||
### Before start, run
|
|
||||||
```
|
|
||||||
virtualenv env
|
|
||||||
./botan-rebuild
|
|
||||||
```
|
|
||||||
|
|
||||||
#### To start just run ( in virtualenv )
|
|
||||||
```
|
|
||||||
./botan-start
|
|
||||||
```
|
|
||||||
|
@ -12,6 +12,6 @@ config["Paths"]["SiteRoot"] = SiteRoot;
|
|||||||
|
|
||||||
bmap = os.path.join( config["Paths"]["Cache"], "botanjs", "bmap.xml" )
|
bmap = os.path.join( config["Paths"]["Cache"], "botanjs", "bmap.xml" )
|
||||||
|
|
||||||
app.conf.update( BROKER_URL = config["BotanJS"]["CeleryBroker"] )
|
app.conf.update( broker_url = config["BotanJS"]["CeleryBroker"] )
|
||||||
|
|
||||||
JWork.buildClassMap.delay( config["BotanJS"]["SrcDir"], bmap )
|
JWork.buildClassMap.delay( config["BotanJS"]["SrcDir"], bmap )
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from sys import platform
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
from botanjs.config import Config as config
|
from botanjs.config import Config as config
|
||||||
|
|
||||||
@ -45,8 +46,6 @@ class Wrapper:
|
|||||||
with open( loc, "rb" ) as f:
|
with open( loc, "rb" ) as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
|
|
||||||
with NamedTemporaryFile() as f:
|
with NamedTemporaryFile( delete = ( not platform == "win32" ) ) as f:
|
||||||
f.write( content[12:-5] )
|
f.write( content[12:-5] )
|
||||||
os.system( self.C + self.E + " --js " + f.name + " --js_output_file " + loc[:-3] + ".c.js" )
|
os.system( self.C + self.E + " --js " + f.name + " --js_output_file " + loc[:-3] + ".c.js" )
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from sys import platform
|
||||||
from botanjs.config import Config as config
|
from botanjs.config import Config as config
|
||||||
|
|
||||||
COMPILER = config[ "BotanJS" ][ "YuiCompressor" ]
|
COMPILER = config[ "BotanJS" ][ "YuiCompressor" ]
|
||||||
@ -20,5 +21,8 @@ class Wrapper:
|
|||||||
self.C = "java -jar " + COMPILER + " " + " ".join( COMPILER_OPTIONS )
|
self.C = "java -jar " + COMPILER + " " + " ".join( COMPILER_OPTIONS )
|
||||||
|
|
||||||
def compress( self, loc ):
|
def compress( self, loc ):
|
||||||
os.system( self.C + " " + loc + " -o " + loc[:-4] + ".c.css" )
|
|
||||||
|
|
||||||
|
if platform == "win32":
|
||||||
|
loc = loc.replace( "C:", "" ).replace( "\\\\", "/" )
|
||||||
|
|
||||||
|
os.system( self.C + " " + loc + " -o " + loc[:-4] + ".c.css" )
|
||||||
|
@ -18,7 +18,7 @@ class dummyTask( object ):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
class dummyConf:
|
class dummyConf:
|
||||||
def update( self, BROKER_URL = None ):
|
def update( self, broker_url = None ):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class app:
|
class app:
|
||||||
|
@ -99,7 +99,9 @@ class BotanClassResolver:
|
|||||||
|
|
||||||
classMap = ""
|
classMap = ""
|
||||||
flagCompress = True
|
flagCompress = True
|
||||||
|
oModeIfSizelt = 50 * 1024
|
||||||
returnHash = False
|
returnHash = False
|
||||||
|
returnDynamic = False
|
||||||
resv = None
|
resv = None
|
||||||
|
|
||||||
def __init__( self, jwork, BotanRoot, classMap, cacheRoot ):
|
def __init__( self, jwork, BotanRoot, classMap, cacheRoot ):
|
||||||
@ -122,12 +124,17 @@ class BotanClassResolver:
|
|||||||
|
|
||||||
return content
|
return content
|
||||||
|
|
||||||
def BotanCache( self, t ):
|
def BotanCache( self, srcFile, fileHash, hashContentDynamic ):
|
||||||
content = ""
|
|
||||||
with open( t, "r" ) as f:
|
|
||||||
content = f.read()
|
|
||||||
|
|
||||||
return content
|
for _ in [0]:
|
||||||
|
if hashContentDynamic and os.path.getsize( srcFile ) < self.oModeIfSizelt:
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.returnHash:
|
||||||
|
return fileHash
|
||||||
|
|
||||||
|
with open( srcFile, "r" ) as f:
|
||||||
|
return f.read()
|
||||||
|
|
||||||
def cleanList( self, lista ):
|
def cleanList( self, lista ):
|
||||||
olist = []
|
olist = []
|
||||||
@ -196,7 +203,7 @@ class BotanClassResolver:
|
|||||||
dates.append( os.path.getmtime( os.path.join( self.R, "_this.js" ) ) );
|
dates.append( os.path.getmtime( os.path.join( self.R, "_this.js" ) ) );
|
||||||
|
|
||||||
if self.flagCompress and self.useCache( cFile, dates ):
|
if self.flagCompress and self.useCache( cFile, dates ):
|
||||||
return cFHash if self.returnHash else self.BotanCache( cFile )
|
return self.BotanCache( cFile, cFHash, self.returnDynamic )
|
||||||
|
|
||||||
elif self.useCache( oFile, dates ):
|
elif self.useCache( oFile, dates ):
|
||||||
self.JWork.saveCache(
|
self.JWork.saveCache(
|
||||||
@ -207,7 +214,7 @@ class BotanClassResolver:
|
|||||||
, os.path.join( self.R, "externs" )
|
, os.path.join( self.R, "externs" )
|
||||||
)
|
)
|
||||||
|
|
||||||
return oFHash if self.returnHash else self.BotanCache( oFile )
|
return self.BotanCache( oFile, oFHash, False )
|
||||||
|
|
||||||
def useCache( self, f, dList ):
|
def useCache( self, f, dList ):
|
||||||
if not os.path.exists( f ):
|
if not os.path.exists( f ):
|
||||||
@ -248,7 +255,7 @@ class BotanClassResolver:
|
|||||||
|
|
||||||
outputJs = wrapScope( outputJs )
|
outputJs = wrapScope( outputJs )
|
||||||
|
|
||||||
[ self.JWork.saveCache if self.returnHash else self.JWork.saveCache ][0] (
|
self.JWork.saveCache(
|
||||||
os.path.join( self.CR, md5[0] )
|
os.path.join( self.CR, md5[0] )
|
||||||
, outputJs
|
, outputJs
|
||||||
, "js"
|
, "js"
|
||||||
@ -283,9 +290,7 @@ class BotanClassResolver:
|
|||||||
for f in self.cleanList( cList ):
|
for f in self.cleanList( cList ):
|
||||||
outputCss += self.BotanFile( f )
|
outputCss += self.BotanFile( f )
|
||||||
|
|
||||||
[ self.JWork.saveCache if self.returnHash else self.JWork.saveCache ][0] (
|
self.JWork.saveCache( os.path.join( self.CR, md5[0] ), outputCss, "css" )
|
||||||
os.path.join( self.CR, md5[0] ), outputCss, "css"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.returnHash:
|
if self.returnHash:
|
||||||
return md5[0]
|
return md5[0]
|
||||||
@ -299,13 +304,26 @@ class BotanClassResolver:
|
|||||||
flag = mode[0]
|
flag = mode[0]
|
||||||
requestAPIs = code
|
requestAPIs = code
|
||||||
|
|
||||||
|
# Return compressed contents if possible
|
||||||
|
# otherwise return raw contents
|
||||||
if flag == "o":
|
if flag == "o":
|
||||||
mode = mode[1:]
|
mode = mode[1:]
|
||||||
|
|
||||||
|
# Return raw contents only
|
||||||
elif flag == "r":
|
elif flag == "r":
|
||||||
mode = mode[1:]
|
mode = mode[1:]
|
||||||
self.flagCompress = False
|
self.flagCompress = False
|
||||||
|
|
||||||
|
# Return hashed filenames only
|
||||||
|
elif flag == "h":
|
||||||
|
mode = mode[1:]
|
||||||
|
self.returnHash = True
|
||||||
|
|
||||||
|
# Return hashed filenames if content is larger than self.oModeIfSizelt bytes
|
||||||
|
# otherwise act as "o" mode
|
||||||
else:
|
else:
|
||||||
self.returnHash = True
|
self.returnHash = True
|
||||||
|
self.returnDynamic = True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
requestAPIs = (
|
requestAPIs = (
|
||||||
@ -329,7 +347,8 @@ class BotanClassResolver:
|
|||||||
|
|
||||||
for apis in requestAPIs:
|
for apis in requestAPIs:
|
||||||
|
|
||||||
if apis == None: continue
|
if not apis:
|
||||||
|
continue
|
||||||
|
|
||||||
classList = []
|
classList = []
|
||||||
lookupList = imports
|
lookupList = imports
|
||||||
|
@ -17,7 +17,7 @@ if CeleryExists:
|
|||||||
|
|
||||||
if os.path.exists( "settings.ini" ):
|
if os.path.exists( "settings.ini" ):
|
||||||
from botanjs.config import Config
|
from botanjs.config import Config
|
||||||
app.conf.update( BROKER_URL = Config["BotanJS"]["CeleryBroker"] )
|
app.conf.update( broker_url = Config["BotanJS"]["CeleryBroker"] )
|
||||||
|
|
||||||
else:
|
else:
|
||||||
from botanjs.dummy import app
|
from botanjs.dummy import app
|
||||||
@ -34,7 +34,7 @@ class JWork:
|
|||||||
if mode == "js":
|
if mode == "js":
|
||||||
JWork.compressJs.delay( location, externs )
|
JWork.compressJs.delay( location, externs )
|
||||||
elif mode == "css":
|
elif mode == "css":
|
||||||
JWork.compressCss.delay( location )
|
JWork.compressCss( location )
|
||||||
|
|
||||||
@app.task()
|
@app.task()
|
||||||
def compressJs( md5, externs ):
|
def compressJs( md5, externs ):
|
||||||
@ -54,5 +54,6 @@ class JWork:
|
|||||||
log.info( "Building Class Map" )
|
log.info( "Building Class Map" )
|
||||||
c = ClassMap( src )
|
c = ClassMap( src )
|
||||||
|
|
||||||
|
os.makedirs( os.path.dirname( location ), exist_ok = True )
|
||||||
with open( location, "w" ) as f:
|
with open( location, "w" ) as f:
|
||||||
f.write( c.build() )
|
f.write( c.build() )
|
||||||
|
@ -23,9 +23,9 @@ class WebAPI:
|
|||||||
self.BMap = os.path.join( self.BCache, "bmap.xml" )
|
self.BMap = os.path.join( self.BCache, "bmap.xml" )
|
||||||
|
|
||||||
if brokerURL != None:
|
if brokerURL != None:
|
||||||
CeleryApp.conf.update( BROKER_URL = brokerURL )
|
CeleryApp.conf.update( broker_url = brokerURL )
|
||||||
|
|
||||||
self.app = Flask( __name__, static_url_path = self.BCache, static_folder = self.BCache )
|
self.app = Flask( __name__, static_url_path = "/cache/botanjs", static_folder = self.BCache )
|
||||||
self.app.jinja_env.add_extension( "compressinja.html.HtmlCompressor" )
|
self.app.jinja_env.add_extension( "compressinja.html.HtmlCompressor" )
|
||||||
|
|
||||||
self.app.add_url_rule( "/" , view_func = self.index )
|
self.app.add_url_rule( "/" , view_func = self.index )
|
||||||
@ -33,6 +33,7 @@ class WebAPI:
|
|||||||
self.app.add_url_rule( "/<mode>/<path:code>" , view_func = self.api_request )
|
self.app.add_url_rule( "/<mode>/<path:code>" , view_func = self.api_request )
|
||||||
|
|
||||||
def run( self, *args, **kwargs ):
|
def run( self, *args, **kwargs ):
|
||||||
|
JWork.buildClassMap( self.BRoot, self.BMap )
|
||||||
return self.app.run( *args, **kwargs )
|
return self.app.run( *args, **kwargs )
|
||||||
|
|
||||||
def index( self ):
|
def index( self ):
|
||||||
@ -40,6 +41,10 @@ class WebAPI:
|
|||||||
|
|
||||||
def api_request( self, mode, code ):
|
def api_request( self, mode, code ):
|
||||||
|
|
||||||
|
if mode == "rebuild":
|
||||||
|
JWork.buildClassMap.delay( self.BRoot, self.BMap )
|
||||||
|
return "OK", 200
|
||||||
|
|
||||||
if code == "zpayload":
|
if code == "zpayload":
|
||||||
code = request.args.get( "p" )
|
code = request.args.get( "p" )
|
||||||
|
|
||||||
@ -53,6 +58,8 @@ class WebAPI:
|
|||||||
srvHandler = JCResv( JWork, self.BRoot, self.BMap, self.BCache )
|
srvHandler = JCResv( JWork, self.BRoot, self.BMap, self.BCache )
|
||||||
return Response( srvHandler.getAPI( code, mode = mode ), mimetype = t )
|
return Response( srvHandler.getAPI( code, mode = mode ), mimetype = t )
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
if self.app.config[ "DEBUG" ]:
|
||||||
|
raise
|
||||||
return str(e), 404
|
return str(e), 404
|
||||||
|
|
||||||
|
|
||||||
|
2
main.py
2
main.py
@ -8,7 +8,7 @@ from botanjs.service.webapi import WebAPI
|
|||||||
SiteRoot = os.path.abspath( "." )
|
SiteRoot = os.path.abspath( "." )
|
||||||
|
|
||||||
# Setting the SiteRoot for config
|
# Setting the SiteRoot for config
|
||||||
config["Paths"]["SiteRoot"] = SiteRoot;
|
config["Paths"]["SiteRoot"] = SiteRoot
|
||||||
|
|
||||||
service = WebAPI(
|
service = WebAPI(
|
||||||
jsCache = config["Paths"]["Cache"]
|
jsCache = config["Paths"]["Cache"]
|
||||||
|
@ -12,9 +12,8 @@ Cache = ${SiteRoot}/cache
|
|||||||
|
|
||||||
[BotanJS]
|
[BotanJS]
|
||||||
SrcDir = ${Paths:Runtime}/botanjs/src
|
SrcDir = ${Paths:Runtime}/botanjs/src
|
||||||
CeleryBroker = redis://:${REDIS_PASS}@123.123.123.123:1234/9
|
|
||||||
|
|
||||||
REDIS_PASS = PASSWORD_FOR_REDIS_DB
|
CeleryBroker = redis://:@redis:6379/9
|
||||||
|
|
||||||
ClosureCompiler = /opt/utils/closure.jar
|
ClosureCompiler = /opt/utils/closure.jar
|
||||||
YuiCompressor = /opt/utils/yuicompressor.jar
|
YuiCompressor = /opt/utils/yuicompressor.jar
|
||||||
|
12
windows/app/Dockerfile
Normal file
12
windows/app/Dockerfile
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
FROM astrojs/jre-nanoserver-1809:latest
|
||||||
|
|
||||||
|
RUN pip3 install Flask redis compressinja celery
|
||||||
|
|
||||||
|
RUN New-Item -ItemType "Directory" -Path /opt/utils; \
|
||||||
|
New-Item -ItemType "Directory" -Path /app; \
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; \
|
||||||
|
Invoke-WebRequest -UseBasicParsing -Uri 'https://github.com/tgckpg/BotanJS/releases/download/compressors/closure.jar' -OutFile '/opt/utils/closure.jar' ; \
|
||||||
|
Invoke-WebRequest -UseBasicParsing -Uri 'https://github.com/tgckpg/BotanJS/releases/download/compressors/yuicompressor.jar' -OutFile '/opt/utils/yuicompressor.jar' ;
|
||||||
|
|
||||||
|
EXPOSE 5000
|
||||||
|
WORKDIR /app
|
41
windows/docker-compose.yml
Normal file
41
windows/docker-compose.yml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
version: '3.9'
|
||||||
|
|
||||||
|
services:
|
||||||
|
python:
|
||||||
|
build: pyrt
|
||||||
|
image: astrojs/pyrt-nanoserver-1809
|
||||||
|
jre:
|
||||||
|
build: jre
|
||||||
|
image: astrojs/jre-nanoserver-1809
|
||||||
|
redis:
|
||||||
|
container_name: astrojsdev_redis
|
||||||
|
build: redis
|
||||||
|
web:
|
||||||
|
container_name: astrojsdev_app
|
||||||
|
image: astrojs/app
|
||||||
|
hostname: astrojs.default
|
||||||
|
build:
|
||||||
|
context: ../
|
||||||
|
dockerfile: windows/app/Dockerfile
|
||||||
|
command: [ "python", "main.py" ] # [ "ping", "127.0.0.1", "-n", "9999" ]
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
|
volumes:
|
||||||
|
- ../:C:/app
|
||||||
|
- cache:C:/app/cache
|
||||||
|
tasks:
|
||||||
|
container_name: astrojsdev_compiler
|
||||||
|
image: astrojs/app
|
||||||
|
command: [ "celery", "-A", "botanjs.service.jwork", "worker", "-l", "info", "--pool=solo" ]
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
- web
|
||||||
|
volumes:
|
||||||
|
- ../:C:/app
|
||||||
|
- cache:C:/app/cache
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
cache:
|
||||||
|
temp:
|
9
windows/jre/Dockerfile
Normal file
9
windows/jre/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
FROM astrojs/pyrt-nanoserver-1809:latest as base
|
||||||
|
|
||||||
|
ENV JAVA_HOME=C:\\openjdk-11
|
||||||
|
ENV JAVA_VERSION=11.0.12
|
||||||
|
|
||||||
|
RUN setx PATH "$Env:JAVA_HOME\bin`;$Env:Path" /M
|
||||||
|
|
||||||
|
COPY --from=openjdk:11-jre-nanoserver-1809 /openjdk-11 /openjdk-11
|
||||||
|
RUN echo Verifying install ... && echo java --version && java --version && echo Complete.
|
54
windows/pyrt/dockerfile
Normal file
54
windows/pyrt/dockerfile
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
FROM mcr.microsoft.com/powershell:nanoserver-1809
|
||||||
|
|
||||||
|
SHELL [ "pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';" ]
|
||||||
|
|
||||||
|
RUN $url = 'https://www.python.org/ftp/python/3.7.6/python-3.7.6-embed-amd64.zip'; \
|
||||||
|
Write-host "downloading: $url"; \
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; \
|
||||||
|
New-Item -ItemType Directory /installer > $null ; \
|
||||||
|
Invoke-WebRequest -Uri $url -outfile /installer/Python.zip -verbose; \
|
||||||
|
Expand-Archive /installer/Python.zip -DestinationPath /Python; \
|
||||||
|
Move-Item /Python/python37._pth /Python/python37._pth.save
|
||||||
|
|
||||||
|
### Begin workaround ###
|
||||||
|
# Note that changing user on nanoserver is not recommended
|
||||||
|
# See, https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-base-images#base-image-differences
|
||||||
|
# But we are working around a bug introduced in the nanoserver image introduced in 1809
|
||||||
|
USER ContainerAdministrator
|
||||||
|
|
||||||
|
# This is basically the correct code except for the /M
|
||||||
|
RUN setx PATH "$Env:Path`C:\Python`;C:\Python\Scripts`;" /M
|
||||||
|
|
||||||
|
# We can't
|
||||||
|
# USER ContainerUser
|
||||||
|
### End workaround ###
|
||||||
|
|
||||||
|
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
|
||||||
|
ENV PYTHON_PIP_VERSION 21.2.4
|
||||||
|
# https://github.com/pypa/get-pip
|
||||||
|
ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/4b85d3add912c861aea4a9feaae737a5b7b9cb1c/public/get-pip.py
|
||||||
|
ENV PYTHON_GET_PIP_SHA256 ced8c71489cd46c511677bfe423f37eb88f08f29e9af36ef2679091ec7122d4f
|
||||||
|
|
||||||
|
RUN Write-Host ('Downloading get-pip.py ({0}) ...' -f $env:PYTHON_GET_PIP_URL); \
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
|
||||||
|
Invoke-WebRequest -Uri $env:PYTHON_GET_PIP_URL -OutFile 'get-pip.py'; \
|
||||||
|
Write-Host ('Verifying sha256 ({0}) ...' -f $env:PYTHON_GET_PIP_SHA256); \
|
||||||
|
if ((Get-FileHash 'get-pip.py' -Algorithm sha256).Hash -ne $env:PYTHON_GET_PIP_SHA256) { \
|
||||||
|
Write-Host 'FAILED!'; \
|
||||||
|
exit 1; \
|
||||||
|
}; \
|
||||||
|
\
|
||||||
|
Write-Host ('Installing pip=={0} ...' -f $env:PYTHON_PIP_VERSION); \
|
||||||
|
python get-pip.py \
|
||||||
|
--disable-pip-version-check \
|
||||||
|
--no-cache-dir \
|
||||||
|
('pip=={0}' -f $env:PYTHON_PIP_VERSION) \
|
||||||
|
; \
|
||||||
|
Remove-Item get-pip.py -Force; \
|
||||||
|
\
|
||||||
|
Write-Host 'Verifying pip install ...'; \
|
||||||
|
pip --version; \
|
||||||
|
\
|
||||||
|
Write-Host 'Complete.'
|
||||||
|
|
||||||
|
CMD [ "python.exe" ]
|
27
windows/redis/Dockerfile
Normal file
27
windows/redis/Dockerfile
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
FROM mcr.microsoft.com/powershell:nanoserver-1809
|
||||||
|
|
||||||
|
SHELL [ "pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';" ]
|
||||||
|
|
||||||
|
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; \
|
||||||
|
Invoke-WebRequest -UseBasicParsing -Uri 'https://github.com/tporadowski/redis/releases/download/v5.0.10/Redis-x64-5.0.10.zip' -OutFile 'Redis-x64-5.0.10.zip' ; \
|
||||||
|
Expand-Archive Redis-x64-5.0.10.zip -dest 'C:\\Program Files\\Redis\\' ; \
|
||||||
|
Remove-Item Redis-x64-5.0.10.zip -Force
|
||||||
|
|
||||||
|
User ContainerAdministrator
|
||||||
|
RUN setx Path "C:\Program` Files\Redis`;$Env:Path" /M;
|
||||||
|
User ContainerUser
|
||||||
|
|
||||||
|
WORKDIR 'C:\\Program Files\\Redis'
|
||||||
|
|
||||||
|
RUN Get-Content redis.windows.conf | Where { $_ -notmatch 'bind 127.0.0.1' } | Set-Content redis.openport.conf ; \
|
||||||
|
Get-Content redis.openport.conf | Where { $_ -notmatch 'protected-mode yes' } | Set-Content redis.unprotected.conf ; \
|
||||||
|
Add-Content redis.unprotected.conf 'protected-mode no' ; \
|
||||||
|
Add-Content redis.unprotected.conf 'bind 0.0.0.0' ; \
|
||||||
|
Get-Content redis.unprotected.conf
|
||||||
|
|
||||||
|
EXPOSE 6379
|
||||||
|
|
||||||
|
# Define our command to be run when launching the container
|
||||||
|
CMD .\\redis-server.exe .\\redis.unprotected.conf --port 6379 ; \
|
||||||
|
Write-Host Redis Started... ; \
|
||||||
|
while ($true) { Start-Sleep -Seconds 3600 }
|
Loading…
Reference in New Issue
Block a user