diff --git a/.github/workflows/deploy-traefik.yml b/.github/workflows/deploy-traefik.yml index d131ebd..3dd45d8 100644 --- a/.github/workflows/deploy-traefik.yml +++ b/.github/workflows/deploy-traefik.yml @@ -4,7 +4,7 @@ on: push: branches: [ main ] workflow_dispatch: - + jobs: deploy: runs-on: ubuntu-latest @@ -15,4 +15,4 @@ jobs: username: ${{ secrets.SSH_USER }} host: ${{ secrets.SSH_HOST }} password: ${{ secrets.SSH_PASSWORD }} - script: 'cd && cd traefik/deploy && bash ./php-projects.sh ${{ github.event.repository.name }} ${{ vars.PROJECT_NAME }}' + script: cd && cd traefik/deploy && bash ./php-project.sh ${{ github.actor }} ${{ github.event.repository.name }} ${{ vars.PROJECT_NAME }} '${{ toJSON(vars) }}' diff --git a/database-setup.sh b/database-setup.sh new file mode 100644 index 0000000..182ec8f --- /dev/null +++ b/database-setup.sh @@ -0,0 +1,2 @@ +mysql -u root -p$MYSQL_ROOT_PASSWORD --execute \ +"GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%';" \ No newline at end of file diff --git a/docker-compose.override.yml b/docker-compose.override.yml new file mode 100644 index 0000000..d82fcd2 --- /dev/null +++ b/docker-compose.override.yml @@ -0,0 +1,37 @@ +version: '3.4' + +services: + web: + ports: + - "127.0.0.1:8000:80" + environment: + DB_USER: user + DB_PASSWORD: password + DB_HOST: database + DB_NAME: simplemvc + depends_on: + database: + condition: service_healthy + database: + image: mysql/mysql-server:8.0 + healthcheck: + test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "-uroot", "-prootpassword"] # Command to check health. + interval: 5s # Interval between health checks. + timeout: 5s # Timeout for each health checking. + retries: 20 # Hou many times retries. + start_period: 10s +# container_name: database + volumes: + - ./database-setup.sh:/docker-entrypoint-initdb.d/setup.sh + - db-data:/var/lib/mysql + environment: + MYSQL_USER: user + MYSQL_PASSWORD: password + # Password for root access + MYSQL_ROOT_PASSWORD: rootpassword + ports: + - "3306:3306" + +volumes: + db-data: + name: database diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000..0c3d633 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,25 @@ +version: '3.4' + +services: + web: + build: . + container_name: ${PROJECT_NAME:-project}-web + volumes: + - ./:/var/www + restart: always + networks: + - proxy + environment: + DB_USER: ${USER_NAME} + DB_PASSWORD: ${USER_PASSWORD} + DB_HOST: ${DATABASE_SUBDOMAIN_NAME}-db + DB_NAME: ${DB_NAME} + labels: + - "traefik.enable=true" + - "traefik.docker.network=proxy" + - "traefik.http.routers.${PROJECT_NAME:-project}-secure.entrypoints=websecure" + - "traefik.http.routers.${PROJECT_NAME:-project}-secure.rule=Host(`${PROJECT_NAME:-project}.${HOST:-localhost}`)" + +networks: + proxy: + external: true diff --git a/docker-compose.yml b/docker-compose.yml index d6fe19b..a8ad6a4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,25 +1,7 @@ version: '3.4' services: - web: - build: . - container_name: ${PROJECT_NAME:-project}-web - volumes: - - ./:/var/www - restart: always - networks: - - proxy - environment: - DB_USER: ${USER_NAME} - DB_PASSWORD: ${USER_PASSWORD} - DB_HOST: ${DATABASE_SUBDOMAIN_NAME}-db - DB_NAME: ${DB_NAME} - labels: - - "traefik.enable=true" - - "traefik.docker.network=proxy" - - "traefik.http.routers.${PROJECT_NAME:-project}-secure.entrypoints=websecure" - - "traefik.http.routers.${PROJECT_NAME:-project}-secure.rule=Host(`${PROJECT_NAME:-project}.${HOST:-localhost}`)" - -networks: - proxy: - external: true + web: + build: . + volumes: + - ./:/var/www