diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..2e471a2 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,44 @@ +name: Deploy to DigitalOcean + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + deploy: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.11"] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + + + + - name: CICD + uses: appleboy/ssh-action@v0.1.2 + with: + host: ${{secrets.SSH_HOST_RQ}} + key: ${{secrets.SSH_KEY_RQ}} + username: ${{secrets.SSH_USERNAME_RQ}} + + script: | + if [ ! -d "rice_trader" ]; then + mkdir rice_trader + fi + cd rice_trader/ + docker container prune -f + docker image prune -f + docker volume prune -f + docker-compose pull + docker-compose down + docker-compose up -d \ No newline at end of file diff --git a/Pipfile b/Pipfile index f68283f..56aa51b 100644 --- a/Pipfile +++ b/Pipfile @@ -12,6 +12,7 @@ pytest = "*" pytest-cov = "*" coverage = "*" mongomock = "*" +pytest--cov = "*" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index cfd3df4..348827c 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "ab02b79494d5213f3fad136a7f252e0bd737343c1ed5fbd5694710aefbbfc27e" + "sha256": "92eb59d1e903ff9a0d51496e9acfa4874d7eb38588c8531a7869ef9f3fb61be2" }, "pipfile-spec": 6, "requires": { diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ccfa6f8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,24 @@ +version: "3.11" + +services: + mongodb: + image: mongo:latest + container_name: mongo2 + ports: + - "27017:27017" + + frontend: + build: ./web-app # build the Docker image from the Dockerfile in the front-end directory + image: kingslayerrq/rice:v1 + container_name: traderwebappcontainer + ports: + - "3000:3000" + depends_on: + - mongodb + + + + + +volumes: + mongodb-data: \ No newline at end of file diff --git a/web-app/Dockerfile b/web-app/Dockerfile index 07c8f16..6eec4d1 100644 --- a/web-app/Dockerfile +++ b/web-app/Dockerfile @@ -4,20 +4,18 @@ WORKDIR /web-app COPY requirements.txt ./ -RUN apt-get update && apt-get install -y ffmpeg -RUN apt-get -y install libasound-dev -RUN apt-get -y install portaudio19-dev + RUN pip install --no-cache-dir -r requirements.txt COPY . /web-app -EXPOSE 5000 +EXPOSE 3000 # Run app.py when the container launches COPY . /app -EXPOSE 5000 +EXPOSE 3000 CMD ["python", "app.py"] \ No newline at end of file diff --git a/web-app/app.py b/web-app/app.py index 9185b91..afa36c4 100644 --- a/web-app/app.py +++ b/web-app/app.py @@ -11,7 +11,7 @@ app = Flask('Trader') app.secret_key = 'pass' -client = MongoClient("mongodb://localhost:27017/") +client = MongoClient("mongodb://mongo2:27017/") db = client["trade_database"] @app.route('/Trade') @@ -296,4 +296,4 @@ def UserProfile(): if __name__ == "__main__": - app.run(host="0.0.0.0", port=int(os.getenv("PORT", "5000")), debug=True) + app.run(host="0.0.0.0", port=int(os.getenv("PORT", "3000")), debug=True)