Skip to content

Commit

Permalink
changed compose, added the gha dockerfiles, update the gha scritp
Browse files Browse the repository at this point in the history
  • Loading branch information
kiloutyg committed Mar 21, 2024
1 parent d5017f2 commit 4e700fe
Show file tree
Hide file tree
Showing 11 changed files with 484 additions and 72 deletions.
9 changes: 9 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=posigndb
MYSQL_USER=user
MYSQL_PASSWORD=pass
HOSTNAME=slanlp0033.ad.ponet

###> symfony/framework-bundle ###
APP_ENV=dev

45 changes: 32 additions & 13 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
API_IMAGE_NAME: ${{ github.repository }}-API
FRONT_IMAGE_NAME: ${{ github.repository }}-FRONT
API_IMAGE_NAME: ${{ github.repository }}api
FRONT_IMAGE_NAME: ${{ github.repository }}front


jobs:
Expand All @@ -41,9 +41,7 @@ jobs:
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
with:
cosign-release: 'v2.1.1'
uses: sigstore/[email protected]

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
Expand All @@ -61,13 +59,24 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract Pull Request Number
- name: Get Pull Request number
id: pr_number
run: echo "PR_NUMBER=$(echo ${GITHUB_REF#refs/pull/} | cut -d'/' -f1)" >> $GITHUB_ENV
if: github.event_name == 'pull_request'

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.API_IMAGE_NAME }}
images: ${{ env.REGISTRY }}/${{ env.API_IMAGE_NAME }}api
tags: |
type=ref,event=branch
type=ref,event=tag
type=sha
type=raw,value=${{ env.API_IMAGE_NAME }}:pr-${{ steps.pr_number.outputs.number }},enable=${{ github.event_name == 'pull_request' }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
Expand All @@ -92,7 +101,7 @@ jobs:
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
DIGEST: ${{ steps.build-and-push-API.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
Expand All @@ -115,9 +124,8 @@ jobs:
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
with:
cosign-release: 'v2.1.1'
uses: sigstore/[email protected]


# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
Expand All @@ -134,18 +142,29 @@ jobs:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract Pull Request Number
- name: Get Pull Request number
id: pr_number
run: echo "PR_NUMBER=$(echo ${GITHUB_REF#refs/pull/} | cut -d'/' -f1)" >> $GITHUB_ENV
if: github.event_name == 'pull_request'

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.FRONT_IMAGE_NAME }}
images: ${{ env.REGISTRY }}/${{ env.FRONT_IMAGE_NAME }}prod
tags: |
type=ref,event=branch
type=ref,event=tag
type=sha
type=raw,value=${{ env.FRONT_IMAGE_NAME }}:pr-${{ steps.pr_number.outputs.number }},enable=${{ github.event_name == 'pull_request' }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image API
- name: Build and push Docker image FRONT
id: build-and-push-FRONT
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
Expand All @@ -166,7 +185,7 @@ jobs:
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
DIGEST: ${{ steps.build-and-push-FRONT.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
/database*
/API/Docs/
.vscode
config.user.inc.php
docker-compose.override.yml
21 changes: 21 additions & 0 deletions API/DockerfileGHA
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Fetching the minified node image on apline linux
FROM node:21-bookworm

# Setting up the work directory
WORKDIR /var/www

# Get Timezone data Package
RUN apt-get install tzdata

# Set the timezone (2 ways)
ENV TZ=Europe/Paris
RUN rm /etc/localtime
RUN ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime

COPY . .

# Install the dependencies
RUN npm install

# Exposing server port
EXPOSE 52200
7 changes: 7 additions & 0 deletions API/prod-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

export NODE_ENV=development;

npm install;

npm start;
17 changes: 17 additions & 0 deletions FRONT/DockerfileGHA
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Fetching the minified node image on apline linux
FROM httpd:alpine

# Setting up the work directory
WORKDIR /usr/local/apache2/htdocs/

# Get Timezone data Package
RUN apk add --no-cache tzdata

# Set the timezone (2 ways)
ENV TZ=Europe/Paris
RUN ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime

COPY . .

# Exposing server port
EXPOSE 80
5 changes: 5 additions & 0 deletions config.user.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

require '/etc/phpmyadmin/config.secret.inc.php';

$cfg['Servers'][$i]['auth_type'] = 'http';
53 changes: 0 additions & 53 deletions docker-compose.override.yaml

This file was deleted.

10 changes: 5 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ services:
image: mariadb:latest
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: posign
MYSQL_USER: user
MYSQL_PASSWORD: pass
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
volumes:
- ./database:/var/lib/mysql
- ./database_data:/var/lib/mysql
ports:
- "3306"
networks:
Expand Down
Loading

0 comments on commit 4e700fe

Please sign in to comment.