Added docker windows container for dev
This commit is contained in:
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 }
|
Reference in New Issue
Block a user