diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml new file mode 100644 index 0000000..c70ab96 --- /dev/null +++ b/.github/workflows/build_push.yml @@ -0,0 +1,25 @@ +name: Build_Push + +on: + push: + branches: + - main + +permissions: + contents: read + packages: write + +jobs: + docker_build_test: + runs-on: ubuntu-24.04 + name: Docker_build + steps: + - uses: actions/checkout@v4 + + - name: Build the Docker image + run: docker build -t ghcr.io/gabrielpalmar/hivebox:$(cat version.txt) . + + - name: Push Docker image to GHCR + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + docker push ghcr.io/gabrielpalmar/hivebox:$(cat version.txt) \ No newline at end of file diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 2cbedd2..6a0adf0 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -18,10 +18,10 @@ jobs: steps: - uses: actions/checkout@v4 - name: Build the Docker image - run: docker build . --file docker/Dockerfile --tag pommed3rre/hivebox:$(cat version.txt) + run: docker build -t gabrielpalmar/hivebox:$(cat version.txt) . - name: Run Docker container - run: docker run -d -p 5000:5000 pommed3rre/hivebox:$(cat version.txt) + run: docker run -d -p 5000:5000 gabrielpalmar/hivebox:$(cat version.txt) - name: Set up Python for testing uses: actions/setup-python@v5 diff --git a/.github/workflows/hadolint.yml b/.github/workflows/hadolint.yml index 3118bcb..5a9b5a1 100644 --- a/.github/workflows/hadolint.yml +++ b/.github/workflows/hadolint.yml @@ -12,11 +12,10 @@ permissions: contents: read jobs: - hadolint: + hadolint-linting: runs-on: ubuntu-24.04 - name: Hadolint steps: - uses: actions/checkout@v4 - uses: hadolint/hadolint-action@v3.1.0 with: - dockerfile: docker/Dockerfile + dockerfile: Dockerfile \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1cf8e0c..e50c92d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /env /__pycache__ /out.txt +/tests/__pycache__ \ No newline at end of file diff --git a/docker/Dockerfile b/Dockerfile similarity index 95% rename from docker/Dockerfile rename to Dockerfile index eba5c29..10ec59e 100644 --- a/docker/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ RUN addgroup -S appgroup && adduser -S -G appgroup appuser WORKDIR /app -COPY app/ /app/app/ +COPY /app/ /app/app/ COPY version.txt requirements.txt /app/ RUN pip install --no-cache-dir -r /app/requirements.txt --require-hashes && \ diff --git a/k8s/deployment.yml b/k8s/deployment.yml new file mode 100644 index 0000000..04f4dfd --- /dev/null +++ b/k8s/deployment.yml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hivebox + labels: + app: hivebox +spec: + replicas: 2 + selector: + matchLabels: + app: hivebox + template: + metadata: + labels: + app: hivebox + spec: + containers: + - name: hivebox + image: ghcr.io/gabrielpalmar/hivebox:latest + ports: + - containerPort: 5000 + env: + - name: FLASK_ENV + value: "production" + resources: + limits: + memory: "512Mi" + cpu: "500m" + requests: + memory: "256Mi" + cpu: "250m" diff --git a/k8s/service.yml b/k8s/service.yml new file mode 100644 index 0000000..1afb8b8 --- /dev/null +++ b/k8s/service.yml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: hivebox-service + labels: + app: hivebox +spec: + selector: + app: hivebox + ports: + - port: 80 + targetPort: 5000 + protocol: TCP + type: LoadBalancer diff --git a/tests/test_main.py b/tests/test_main.py index 7c9ec55..ac133a7 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,4 +1,4 @@ -'''This module contains the test cases for the main module.''' +'''This module contains the test cases for the main module with VCR cassettes.''' import sys import re import os diff --git a/version.txt b/version.txt index 9325c3c..60a2d3e 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.3.0 \ No newline at end of file +0.4.0 \ No newline at end of file