liuyuqi-dellpc 4 years ago
commit
e9cb99d425
10 changed files with 136 additions and 0 deletions
  1. 24 0
      .dockerignore
  2. 1 0
      .gitignore
  3. 16 0
      Dockerfile
  4. 26 0
      README.md
  5. 10 0
      docker-compose.debug.yml
  6. 8 0
      docker-compose.yml
  7. 27 0
      hello_world.py
  8. 18 0
      num_list.csv
  9. 1 0
      requirements.txt
  10. 5 0
      run.sh

+ 24 - 0
.dockerignore

@@ -0,0 +1,24 @@
+**/.classpath
+**/.dockerignore
+**/.env
+**/.git
+**/.gitignore
+**/.project
+**/.settings
+**/.toolstarget
+**/.vs
+**/.vscode
+**/*.*proj.user
+**/*.dbmdl
+**/*.jfm
+**/azds.yaml
+**/bin
+**/charts
+**/docker-compose*
+**/Dockerfile*
+**/node_modules
+**/npm-debug.log
+**/obj
+**/secrets.dev.yaml
+**/values.dev.yaml
+README.md

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+/.idea

+ 16 - 0
Dockerfile

@@ -0,0 +1,16 @@
+FROM kfwkfulq.mirror.aliyuncs.com/library/python:3.6
+LABEL Name=docker-competition Version=1.0.1
+RUN mkdir -p ~/.pip
+RUN echo '\n\
+    [global] \n\
+    trusted-host=mirrors.aliyun.com \n\
+    index-url=https://mirrors.aliyun.com/pypi/simple/ \
+    ' > ~/.pip/pip.conf
+
+WORKDIR /
+ADD requirements.txt /
+RUN python3 -m pip install -r requirements.txt
+
+ADD . /
+
+CMD ["sh", "run.sh"]

+ 26 - 0
README.md

@@ -0,0 +1,26 @@
+
+## docker-competition
+
+阿里云天池 docker 比赛
+
+https://tianchi.aliyun.com/competition/entrance/231759/information
+
+
+## 提交 sample
+
+生成入口脚本run.sh,放置于镜像工作目录。运行后生成结果result.json放置于工作目录(与run.sh同目录),评分系统将根据result.json进行打分
+
+{  
+    "Q1":"Hello world", 
+    "Q2":sum值, 
+    "Q3":[top10_list] 
+}
+
+
+## 容器运行
+
+
+```
+docker run -it dokcer-competition:latest /bin/bash
+
+```

+ 10 - 0
docker-compose.debug.yml

@@ -0,0 +1,10 @@
+version: '2.1'
+
+services:
+  docker-competition:
+    image: docker-competition
+    build:
+      context: .
+      dockerfile: Dockerfile
+    ports:
+      - 3000:3000

+ 8 - 0
docker-compose.yml

@@ -0,0 +1,8 @@
+version: '2.1'
+
+services:
+  docker-competition:
+    image: docker-competition
+    build: .
+    ports:
+      - 3000:3000

+ 27 - 0
hello_world.py

@@ -0,0 +1,27 @@
+import os,sys
+import json
+import numpy as np
+
+def run():
+    res = {"Q1": "Hello world","Q2":0,"Q3":[]}
+
+    # with open(r"/tcdata/num_list.csv") as file:
+    data = np.loadtxt(r"/tcdata/num_list.csv", delimiter=",", skiprows=0)
+    
+    # 求和
+    res.update({"Q2": int(sum(data))})
+       # res.update({"Q3": [1, 2, 3, 4]})
+
+    # 寻找最大的10个数,从大到小生成一个ListList.
+    data2 = np.sort(data, axis=0)[::-1][0:10]
+    for i in range(len(data2)):
+        res["Q3"].append(int(data2[i]))
+    # res.update({"Q3", []})
+
+    with open("result.json","w") as file:
+        file.write(json.dumps(res))
+    print(json.dumps(res))
+
+if __name__ == "__main__":
+    run()
+  

+ 18 - 0
num_list.csv

@@ -0,0 +1,18 @@
+102
+6
+11
+11
+2
+1
+3
+22
+4
+55
+61
+1
+2
+6
+7
+8
+2
+4

+ 1 - 0
requirements.txt

@@ -0,0 +1 @@
+numpy<1.17

+ 5 - 0
run.sh

@@ -0,0 +1,5 @@
+#!/bin/sh
+
+python hello_world.py
+
+python main.py