diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..360f5d6 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,28 @@ +name: Docker Build + +on: + push: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/fanyi-node:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fa2de14 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM node:18-alpine + +COPY ./lib /home/app/lib +COPY ./tool /home/app/tool +COPY package.json /home/app +COPY router.js /home/app +COPY server.js /home/app + +RUN cd /home/app && npm install + +WORKDIR /home/app + +EXPOSE 3000 +CMD ["node", "server.js"] diff --git a/package.json b/package.json index 5916111..4e4a737 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { - "name": "Fanyi-Node", + "name": "fanyi-node", "version": "1.0.0", "description": "", - "main": "index.js", + "main": "server.js", "type": "module", "scripts": { - "test": "node index.js" + "test": "node server.js" }, "keywords": [], "author": "",