j
This commit is contained in:
parent
47a1b1d3ac
commit
0c78276b12
@ -1,34 +1,32 @@
|
|||||||
version: '1.0'
|
# .gitea/workflows/deploy.yml
|
||||||
|
name: Deploy App to Docker
|
||||||
|
|
||||||
actions:
|
on:
|
||||||
- name: Checkout Repository
|
push:
|
||||||
image: alpine:latest
|
branches:
|
||||||
commands:
|
- main # Trigger on push to the main branch
|
||||||
# Install git and clone the repository
|
|
||||||
- apk add --no-cache git
|
|
||||||
- git clone https://your-gitea-repository-url.git /app
|
|
||||||
|
|
||||||
- name: Build Docker Image
|
jobs:
|
||||||
image: docker:latest
|
deploy:
|
||||||
volumes:
|
runs-on: ubuntu:latest # Use a fresh Ubuntu image to run the job
|
||||||
- /var/run/docker.sock:/var/run/docker.sock # Mount Docker socket to interact with the host Docker daemon
|
|
||||||
commands:
|
|
||||||
# Navigate into the app directory and build the Docker image
|
|
||||||
- cd /app
|
|
||||||
- docker build -t giga_tcg . # Build your Docker image
|
|
||||||
|
|
||||||
- name: Stop and Remove Existing Container (if exists)
|
steps:
|
||||||
image: docker:latest
|
- name: Checkout code
|
||||||
volumes:
|
uses: actions/checkout@v2 # Checkout the repository's code to the runner
|
||||||
- /var/run/docker.sock:/var/run/docker.sock # Mount Docker socket
|
|
||||||
commands:
|
|
||||||
# Stop and remove any existing container with the same name
|
|
||||||
- docker rm -f giga_tcg_container || true # If the container doesn't exist, continue without error
|
|
||||||
|
|
||||||
- name: Run New Docker Container
|
- name: Set up Docker
|
||||||
image: docker:latest
|
uses: docker/setup-buildx-action@v1 # Set up Docker Buildx, which is used for building images
|
||||||
volumes:
|
with:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock # Mount Docker socket
|
version: 'latest'
|
||||||
commands:
|
|
||||||
# Run the newly built Docker container in detached mode, exposing port 8000
|
- name: Build Docker Image
|
||||||
- docker run -d -p 8000:8000 --name giga_tcg_container giga_tcg
|
run: |
|
||||||
|
docker build -t giga_tcg . # Build the Docker image using the Dockerfile
|
||||||
|
|
||||||
|
- name: Remove existing Docker container
|
||||||
|
run: |
|
||||||
|
docker rm -f giga_tcg_container || true # Remove any existing container with the name
|
||||||
|
|
||||||
|
- name: Run Docker container
|
||||||
|
run: |
|
||||||
|
docker run -d -p 8000:8000 --name giga_tcg_container giga_tcg # Run the new container
|
Loading…
x
Reference in New Issue
Block a user