Browse Source

create diretory

liuyuqi-dellpc 2 years ago
parent
commit
52441fe53b
8 changed files with 191 additions and 0 deletions
  1. 25 0
      .dockerignore
  2. 68 0
      .github/workflows/build.yml
  3. 19 0
      .vscode/launch.json
  4. 40 0
      .vscode/tasks.json
  5. 15 0
      Dockerfile
  6. 12 0
      README.md
  7. 2 0
      convert.go
  8. 10 0
      docker-compose.yml

+ 25 - 0
.dockerignore

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

+ 68 - 0
.github/workflows/build.yml

@@ -0,0 +1,68 @@
+name: Go
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+
+jobs:
+
+  build:
+    name: Build
+    strategy:
+      matrix:
+        os: [ubuntu-latest, macos-latest, windows-latest]
+        include:
+        - os: ubuntu-latest
+          path: |
+            ~/.cache/go-build
+            ~/go/pkg/mod
+        - os: macos-latest
+          path: |
+            ~/Library/Caches/go-build
+            ~/go/pkg/mod
+        - os: windows-latest
+          path: |
+            %LocalAppData%\go-build
+            ~/go/pkg/mod
+    runs-on: ubuntu-latest
+    steps:
+      - name: Set up Go 1.13
+        uses: actions/setup-go@v1
+        with:
+          go-version: 1.13
+        id: go
+
+      - name: Check out code into the Go module directory
+        uses: actions/checkout@v2
+
+      - name: cache
+        id: cache
+        uses: actions/cache@v2
+        with:
+          path: ${{ matrix.path }}
+          key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
+          restore-keys: |
+            ${{ runner.os }}-go-
+
+      - name: Get dependencies
+        run: |
+          go get -v -t -d ./...
+          if [ -f Gopkg.toml ]; then
+              curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
+              dep ensure
+          fi
+        working-directory: ./server
+
+      - name: Build
+        run: go build convert.go
+        working-directory: ./server
+
+      - name: docker push
+        run: |
+          docker login --username=${{ secrets.USERNAME }} --password ${{ secrets.PASSWORD }} ccr.ccs.tencentyun.com
+          docker build . -t jianboy/wordtohtml:v1.0.1
+          docker push jianboy/wordtohtml:v1.0.1
+          docker tag $(docker images jianboy/wordtohtml:v1.0.1 -q) jianboy/wordtohtml:latest
+          docker push jianboy/wordtohtml:latest

+ 19 - 0
.vscode/launch.json

@@ -0,0 +1,19 @@
+{
+    "configurations": [
+        {
+            "name": "Docker: Python - Flask",
+            "type": "docker",
+            "request": "launch",
+            "preLaunchTask": "docker-run: debug",
+            "python": {
+                "pathMappings": [
+                    {
+                        "localRoot": "${workspaceFolder}",
+                        "remoteRoot": "/app"
+                    }
+                ],
+                "projectType": "flask"
+            }
+        }
+    ]
+}

+ 40 - 0
.vscode/tasks.json

@@ -0,0 +1,40 @@
+{
+	"version": "2.0.0",
+	"tasks": [
+		{
+			"type": "docker-build",
+			"label": "docker-build",
+			"platform": "python",
+			"dockerBuild": {
+				"tag": "wordtoxml:latest",
+				"dockerfile": "${workspaceFolder}/Dockerfile",
+				"context": "${workspaceFolder}",
+				"pull": true
+			}
+		},
+		{
+			"type": "docker-run",
+			"label": "docker-run: debug",
+			"dependsOn": [
+				"docker-build"
+			],
+			"dockerRun": {
+				"env": {
+					"FLASK_APP": "垃圾分类\\2-tf分类.py"
+				}
+			},
+			"python": {
+				"args": [
+					"run",
+					"--no-debugger",
+					"--no-reload",
+					"--host",
+					"0.0.0.0",
+					"--port",
+					"5000"
+				],
+				"module": "flask"
+			}
+		}
+	]
+}

+ 15 - 0
Dockerfile

@@ -0,0 +1,15 @@
+FROM kfwkfulq.mirror.aliyuncs.com/library/ubuntu:20.10
+LABEL Name=wordtohtml Version=1.0.1
+EXPOSE 5000
+
+# Install requirements
+RUN apt update && \
+    apt install -y libreoffice
+
+WORKDIR /app
+COPY convert /app
+RUN adduser -u 5678 --disabled-password --gecos "" lyq && chown -R lyq /app
+USER lyq
+
+VOLUME [ "/app" ]
+CMD ["convert"]

+ 12 - 0
README.md

@@ -13,5 +13,17 @@ sudo apt-get install poppler-utils wv unrtf tidy
 go get github.com/JalfResi/justext
 go get github.com/JalfResi/justext
 ```
 ```
 
 
+github action 配置docker参数: USERNAME, PASSWORD, REGISTRY, GITHUB_RUN_NUMBER
 
 
 
 
+## 使用
+
+
+```
+docker pull hub.tencentyun.com/google/wordtohtml:v1.0.1
+
+alias wordtohtml='docker run -it --rm -v `pwd`:/app jianboy/wordtohtml'
+
+alias pdf2htmlEX='docker run -ti --rm -v `pwd`:/pdf bwits/pdf2htmlex pdf2htmlEX'
+pdf2htmlEX --zoom 1 test.pdf
+```

+ 2 - 0
convert.go

@@ -11,6 +11,8 @@ func doCommand(cmd string) {
 }
 }
 
 
 func main() {
 func main() {
+	// if diretory not exist, create it
+	doCommand("mkdir -p output")
 	doCommand("libreoffice --headless --convert-to html *.doc --outdir output")
 	doCommand("libreoffice --headless --convert-to html *.doc --outdir output")
 	doCommand("libreoffice --headless --convert-to html *.docx --outdir output")
 	doCommand("libreoffice --headless --convert-to html *.docx --outdir output")
 }
 }

+ 10 - 0
docker-compose.yml

@@ -0,0 +1,10 @@
+version: '3.4'
+
+services:
+  wordtohtml:
+    image: jianboy/wordtohtml:v1.0.1
+    build:
+      context: .
+      dockerfile: ./Dockerfile
+    ports:
+      - 5000:5000