Guest User

Untitled

a guest
Feb 8th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.61 KB | None | 0 0
  1. // Template for index.html
  2. index: path.resolve(__dirname, '../../dist/index.html'), // /alpine/dist
  3.  
  4. // Paths
  5. assetsRoot: path.resolve(__dirname, '../../dist'), // /alpine/dist
  6.  
  7. from alpine.utils import get_base_path, listfiles
  8. logger.info(os.path.join(get_base_path(), 'dist')) # /alpine/dist
  9. logger.info(listfiles(os.path.join(get_base_path(), 'dist'))) # /alpine/dist
  10.  
  11. import os
  12.  
  13. def listfiles(path):
  14. return [_ for _ in os.listdir(path) if os.path.isfile(os.path.join(path, _))]
  15.  
  16. def get_base_path():
  17. current_directory_path = os.path.realpath(os.path.dirname(__file__))
  18. base_path = os.path.split(os.path.split(current_directory_path)[0])[0]
  19. return base_path
  20.  
  21. FROM python:3.6
  22.  
  23. ENV INSTALL_PATH /alpine
  24. ENV ALPINE_USER alpine
  25.  
  26. RUN apt-get update && apt-get -y install sudo
  27. RUN adduser --disabled-password --gecos '' $ALPINE_USER
  28.  
  29. RUN mkdir -p $INSTALL_PATH
  30. WORKDIR $INSTALL_PATH
  31.  
  32. RUN wget -O nodejs.sh https://deb.nodesource.com/setup_8.x
  33. && bash ./nodejs.sh
  34. && apt-get install -y nodejs
  35. && apt-get install -y build-essential
  36. && rm ./nodejs.sh
  37.  
  38. COPY requirements.txt requirements.txt
  39. RUN pip install -r requirements.txt
  40.  
  41. COPY js/build js/build
  42. COPY js/config js/config
  43. COPY js/package-lock.json js/package-lock.json
  44. COPY js/package.json js/package.json
  45. WORKDIR $INSTALL_PATH/js
  46. RUN npm install
  47. WORKDIR $INSTALL_PATH
  48.  
  49. COPY js js
  50. WORKDIR $INSTALL_PATH/js
  51. RUN npm run build
  52. WORKDIR $INSTALL_PATH
  53.  
  54. COPY . .
  55. RUN cp config/config.yml.template config/config.yml
  56.  
  57. RUN echo $INSTALL_PATH
  58. RUN ls -la $INSTALL_PATH
  59. RUN echo $INSTALL_PATH/dist
  60. RUN ls -la $INSTALL_PATH/dist
  61.  
  62. CMD sudo -u $ALPINE_USER python manage.py api run
  63.  
  64. version: '2'
  65.  
  66. services:
  67. api:
  68. build: .
  69. volumes:
  70. - '.:/alpine'
  71. ports:
  72. - '8000:8000'
  73. links:
  74. - postgres:postgres
  75. postgres:
  76. image: 'postgres:10'
  77. volumes:
  78. - './tmp/postgres:/var/lib/postgresql/data'
  79. ports:
  80. - '5432:5432'
  81. environment:
  82. - POSTGRES_PASSWORD=password
  83. - POSTGRES_USER=alpine
  84. - POSTGRES_DB=alpine
  85.  
  86. Step 25/29 : RUN echo $INSTALL_PATH
  87. ---> Running in a62b3fa4ce75
  88. /alpine
  89. ---> 993396566775
  90. Removing intermediate container a62b3fa4ce75
  91. Step 26/29 : RUN ls -la $INSTALL_PATH
  92. ---> Running in 1a2688436868
  93. total 80
  94. drwxr-xr-x 15 root root 4096 Feb 8 15:14 .
  95. drwxr-xr-x 85 root root 4096 Feb 8 15:14 ..
  96. -rw-r--r-- 1 root root 1026 Feb 8 15:13 Dockerfile
  97. -rw-r--r-- 1 root root 0 Aug 17 06:06 README.md
  98. -rw-r--r-- 1 root root 0 Aug 17 06:04 __init__.py
  99. drwxr-xr-x 2 root root 4096 Feb 8 15:14 config
  100. drwxr-xr-x 3 root root 4096 Feb 8 04:22 dist
  101. -rw-r--r-- 1 root root 379 Feb 8 15:13 docker-compose.yml
  102. drwxr-xr-x 17 root root 4096 Feb 7 19:20 js
  103. -rw-r--r-- 1 root root 319 Oct 2 19:19 manage.py
  104. drwxr-xr-x 4 root root 4096 Oct 10 19:01 migrations
  105. drwxr-xr-x 8 root root 4096 Jan 9 16:31 alpine
  106. -rw-r--r-- 1 root root 738 Feb 7 17:04 requirements.txt
  107. ---> 634ae19fd35c
  108. Removing intermediate container 1a2688436868
  109. Step 27/29 : RUN echo $INSTALL_PATH/dist
  110. ---> Running in 2134107ac398
  111. /alpine/dist
  112. ---> 4a692f89324f
  113. Removing intermediate container 2134107ac398
  114. Step 28/29 : RUN ls -la $INSTALL_PATH/dist
  115. ---> Running in 06d954f83c8f
  116. total 16
  117. drwxr-xr-x 3 root root 4096 Feb 8 04:22 .
  118. drwxr-xr-x 15 root root 4096 Feb 8 15:14 ..
  119. -rw-r--r-- 1 root root 504 Feb 8 04:22 index.html
  120. drwxr-xr-x 4 root root 4096 Feb 8 04:22 static
  121. ---> 17378436f04c
  122. Removing intermediate container 06d954f83c8f
  123. Step 29/29 : CMD sudo -u $ALPINE_USER python manage.py api run
  124. ---> Running in 4952b6b65fc1
  125. ---> a3d3ac2d93dc
  126. Removing intermediate container 4952b6b65fc1
  127. Successfully built a3d3ac2d93dc
  128. Successfully tagged alpine_api:latest
  129. Starting alpine_postgres_1 ...
  130. Starting alpine_postgres_1 ... done
  131. Recreating alpine_api_1 ...
  132. Recreating alpine_api_1 ... done
  133. Attaching to alpine_postgres_1, alpine_api_1
  134. postgres_1 | 2018-02-08 15:14:25.483 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
  135. postgres_1 | 2018-02-08 15:14:25.483 UTC [1] LOG: listening on IPv6 address "::", port 5432
  136. postgres_1 | 2018-02-08 15:14:25.521 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
  137. postgres_1 | 2018-02-08 15:14:25.598 UTC [23] LOG: database system was shut down at 2018-02-08 15:13:20 UTC
  138. postgres_1 | 2018-02-08 15:14:25.627 UTC [1] LOG: database system is ready to accept connections
  139. api_1 | 2018-02-08 15:14:26,601 - alpine.app/_init_sanic - INFO - /alpine/dist
  140. api_1 | Traceback (most recent call last):
  141. api_1 | File "manage.py", line 19, in <module>
  142. api_1 | cli()
  143. api_1 | File "/usr/local/lib/python3.6/site-packages/click/core.py", line 722, in __call__
  144. api_1 | return self.main(*args, **kwargs)
  145. api_1 | File "/usr/local/lib/python3.6/site-packages/click/core.py", line 697, in main
  146. api_1 | rv = self.invoke(ctx)
  147. api_1 | File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
  148. api_1 | return _process_result(sub_ctx.command.invoke(sub_ctx))
  149. api_1 | File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
  150. api_1 | return _process_result(sub_ctx.command.invoke(sub_ctx))
  151. api_1 | File "/usr/local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
  152. api_1 | return ctx.invoke(self.callback, **ctx.params)
  153. api_1 | File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
  154. api_1 | return callback(*args, **kwargs)
  155. api_1 | File "/alpine/alpine/cli/api.py", line 55, in run
  156. api_1 | app = AlpineApp(config_path=config_path)
  157. api_1 | File "/alpine/alpine/app.py", line 80, in __init__
  158. api_1 | self._init_sanic()
  159. api_1 | File "/alpine/alpine/app.py", line 89, in _init_sanic
  160. api_1 | logger.info(listfiles(os.path.join(get_base_path(), 'dist')))
  161. api_1 | File "/alpine/alpine/utils/__init__.py", line 42, in listfiles
  162. api_1 | return [_ for _ in os.listdir(path) if os.path.isfile(os.path.join(path, _))]
  163. api_1 | FileNotFoundError: [Errno 2] No such file or directory: '/alpine/dist'
  164. alpine_api_1 exited with code 1
  165.  
  166. 2018-02-08 15:34:34,920 - alpine.app/_init_sanic - INFO - /alpine/dist
  167. 2018-02-08 15:34:34,921 - alpine.app/_init_sanic - INFO - ['index.html']
  168. [2018-02-08 15:34:35 +0000] [1] [INFO] Goin' Fast @ http://0.0.0.0:8000
  169. 2018-02-08 15:34:35,126 - alpine.app/setup_db - INFO - [postgres] starting...
  170. 2018-02-08 15:34:35,130 - alpine.app/setup_db - INFO - [postgres] starting...
  171. 2018-02-08 15:34:35,133 - alpine.app/setup_db - INFO - [postgres] starting...
  172. 2018-02-08 15:34:35,142 - alpine.app/setup_db - INFO - [postgres] starting...
Add Comment
Please, Sign In to add comment