-
Notifications
You must be signed in to change notification settings - Fork 22
Ci cd/put docker on project #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| __pycache__ | ||
| *.pyc | ||
| *.pyo | ||
| *.pyd | ||
| .Python | ||
| .env | ||
| .git | ||
| .gitignore | ||
| Dockerfile | ||
| docker-compose.yml | ||
| *.md | ||
| assets | ||
| tests | ||
| .pytest_cache |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| name: CI/CD PROD | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v[0-9]+.[0-9]+.[0-9]+' | ||
|
|
||
| jobs: | ||
| build: | ||
| timeout-minutes: 3 | ||
| name: build | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write | ||
| contents: write | ||
| actions: read | ||
| checks: write | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@main | ||
|
|
||
| - name: Config QEMU | ||
| uses: docker/setup-qemu-action@v3.2.0 | ||
| with: | ||
| platforms: linux/amd64 | ||
|
|
||
| - name: Config Docker Buildx | ||
| uses: docker/setup-buildx-action@v3.7.1 | ||
| with: | ||
| platforms: linux/amd64 | ||
|
|
||
| - name: Login to Docker Hub | ||
| uses: docker/login-action@v3.3.0 | ||
| with: | ||
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
| password: ${{ secrets.DOCKER_HUB_TOKEN }} | ||
|
|
||
| - name: Build and Publish Image to Docker Hub | ||
| run: | | ||
| docker build -t r4deu51/api-b3:${{ github.ref_name }} . | ||
| docker tag r4deu51/api-b3:${{ github.ref_name }} docker.io/r4deu51/api-b3:${{ github.ref_name }} | ||
| docker push docker.io/r4deu51/api-b3:${{ github.ref_name }} | ||
|
|
||
| # ============================================ | ||
| # DEPLOY | ||
| # ============================================ | ||
| deploy: | ||
| timeout-minutes: 1 | ||
| needs: build | ||
| name: deploy | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write | ||
| contents: read | ||
| actions: read | ||
| checks: write | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@main | ||
|
|
||
| - name: Deploy Image | ||
| uses: ramonpaolo/action-zenifra@main | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using floating branch reference '@main' for custom action is a security risk. If the main branch is compromised or changed, deployments could execute arbitrary code. Consider pinning to a specific commit hash for supply chain security. |
||
| with: | ||
| PROJECT_ID: ${{ secrets.ZENIFRA_PROJECT_ID_PROD }} | ||
| API_KEY: ${{ secrets.ZENIFRA_API_KEY_PROD }} | ||
| IMAGE: docker.io/r4deu51/api-b3:${{ github.ref_name }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| name: CI/CD STG | ||
|
|
||
| on: | ||
| push: | ||
| branches: [master] | ||
| pull_request: | ||
| branches: [master] | ||
|
|
||
| jobs: | ||
| build: | ||
| timeout-minutes: 3 | ||
| name: build | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write | ||
| contents: write | ||
| actions: read | ||
| checks: write | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@main | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using a version tag (e.g., |
||
|
|
||
| - name: Config QEMU | ||
| uses: docker/setup-qemu-action@v3.2.0 | ||
| with: | ||
| platforms: linux/amd64 | ||
|
|
||
| - name: Config Docker Buildx | ||
| uses: docker/setup-buildx-action@v3.7.1 | ||
| with: | ||
| platforms: linux/amd64 | ||
|
|
||
| - name: Login to Docker Hub | ||
| uses: docker/login-action@v3.3.0 | ||
| with: | ||
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
| password: ${{ secrets.DOCKER_HUB_TOKEN }} | ||
|
|
||
| - name: Build and Publish Image to Docker Hub | ||
| run: | | ||
| docker build -t r4deu51/api-b3:${{ github.sha }} . | ||
| docker tag r4deu51/api-b3:${{ github.sha }} docker.io/r4deu51/api-b3:${{ github.sha }} | ||
| docker push docker.io/r4deu51/api-b3:${{ github.sha }} | ||
|
|
||
| # ============================================ | ||
| # DEPLOY | ||
| # ============================================ | ||
| deploy: | ||
| timeout-minutes: 1 | ||
| needs: build | ||
| name: deploy | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write | ||
| contents: read | ||
| actions: read | ||
| checks: write | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@main | ||
|
|
||
| - name: Deploy Image | ||
| uses: ramonpaolo/action-zenifra@main | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using floating branch reference '@main' for custom action is a security risk. If the main branch is compromised or changed, deployments could execute arbitrary code. Consider pinning to a specific commit hash for supply chain security. |
||
| with: | ||
| PROJECT_ID: ${{ secrets.ZENIFRA_PROJECT_ID_STG }} | ||
| API_KEY: ${{ secrets.ZENIFRA_API_KEY_STG }} | ||
| IMAGE: docker.io/r4deu51/api-b3:${{ github.sha }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| FROM python:3.13-slim | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| RUN apt-get update && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| COPY requirements.txt . | ||
|
|
||
| RUN pip install --no-cache-dir -r requirements.txt | ||
|
|
||
| COPY ./ ./ | ||
|
|
||
| EXPOSE 8000 | ||
|
|
||
| RUN addgroup -S appgroup && adduser -S appuser -G appgroup | ||
|
|
||
| USER appuser | ||
|
|
||
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a version tag (e.g.,
@v4) instead of@mainforactions/checkoutto prevent breaking changes from being automatically pulled.