diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3312991..ea12b97 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: Automatic deployment +name: Automatic deployments on: workflow_dispatch: @@ -6,7 +6,6 @@ on: tags: - '*' - # GLOBAL ENVIRONMENT VARIABLES env: SFTP_HOSTNAME: ${{ secrets.SFTP_HOSTNAME }} @@ -14,13 +13,19 @@ env: SFTP_USER: ${{ secrets.SFTP_USER }} SFTP_PASSWORD: ${{ secrets.SFTP_PASSWORD }} SFTP_REMOTE_PATH: '/home/${{ secrets.SFTP_USER }}/www' + OCI_TENANCY_NS: axkiihq3lcps + OCI_REGISTRY: eu-paris-1.ocir.io + OCI_REPOSITORY: grenadille/website + OCI_GITHUB_USERNAME: ${{ secrets.OCI_GITHUB_USERNAME }} + OCI_GITHUB_PASSWORD: ${{ secrets.OCI_GITHUB_PASSWORD }} + DOCKERFILE: docker/Dockerfile jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Cache node modules uses: actions/cache@v2 @@ -39,10 +44,38 @@ jobs: - name: Deploy uses: wlixcc/SFTP-Deploy-Action@v1.2.4 with: - username: ${{ env.SFTP_USER }} - port: ${{ env.SFTP_PORT }} - server: ${{ env.SFTP_HOSTNAME }} - password: ${{ env.SFTP_PASSWORD }} - local_path: './dist/*' - remote_path: ${{ env.SFTP_REMOTE_PATH }} - sftp_only: true + username: ${{ env.SFTP_USER }} + port: ${{ env.SFTP_PORT }} + server: ${{ env.SFTP_HOSTNAME }} + password: ${{ env.SFTP_PASSWORD }} + local_path: './dist/*' + remote_path: ${{ env.SFTP_REMOTE_PATH }} + sftp_only: true + + deploy-oci: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to OCIR + uses: docker/login-action@v3 + with: + registry: ${{ env.OCI_REGISTRY }} + username: ${{ env.OCI_TENANCY_NS }}/${{ env.OCI_GITHUB_USERNAME }} + password: ${{ env.OCI_GITHUB_PASSWORD }} + + - name: Set variables + run: | + echo "REPOSITORY=${{ env.OCI_REGISTRY }}/${{ env.OCI_TENANCY_NS }}/${{ env.OCI_REPOSITORY }}" >> $GITHUB_ENV + + - name: Build and push Docker image with latest tag + run: | + DOCKER_BUILDKIT=1 docker build -f ${{ env.DOCKERFILE }} -t ${{ env.REPOSITORY }}:latest . + docker push ${{ env.REPOSITORY }}:latest + + - name: Add version tag + if: startsWith(github.ref, 'refs/tags/') + run: | + docker tag ${{ env.REPOSITORY }}:latest ${{ env.REPOSITORY }}:${GITHUB_REF#refs/tags/} + docker push ${{ env.REPOSITORY }}:${GITHUB_REF#refs/tags/} diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..cfaccba --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,13 @@ +FROM node:21-alpine as builder +RUN mkdir -p /app +WORKDIR /app +COPY package*.json ./ +RUN npm ci +COPY . . +RUN npm run build + +FROM nginx:alpine as runner +COPY --from=builder /app/dist /usr/share/nginx/html +COPY --from=builder /app/docker/default.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/docker/default.conf b/docker/default.conf new file mode 100644 index 0000000..06805d6 --- /dev/null +++ b/docker/default.conf @@ -0,0 +1,16 @@ +server { + listen 80; + server_name www.grenadille.app; + + client_body_temp_path /tmp/client_body_temp; + proxy_temp_path /tmp/proxy_temp; + fastcgi_temp_path /tmp/fastcgi_temp; + uwsgi_temp_path /tmp/uwsgi_temp; + scgi_temp_path /tmp/scgi_temp; + + location / { + root /usr/share/nginx/html; + index index.html; + error_page 404 404.html; + } +} diff --git a/package.json b/package.json index cc3ec26..d861377 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "scripts": { "start": "parcel 'src/*.html' --lazy --open", "build": "npm run build:clean && npm run build:dist", - "build:dist": "parcel build && cp -fv src/robots.txt src/favicon.ico dist/ && cp -fv src/assets/img/icons/logo.png dist/logo-grenadille.png", + "build:dist": "parcel build 'src/*.html' && cp -fv src/robots.txt src/favicon.ico dist/ && cp -fv src/assets/img/icons/logo.png dist/logo-grenadille.png", "build:clean": "rm -Rf dist .parcel-cache" }, "devDependencies": { diff --git a/src/404.html b/src/404.html new file mode 100644 index 0000000..f6806b1 --- /dev/null +++ b/src/404.html @@ -0,0 +1,71 @@ + + +
+