Skip to content

Commit

Permalink
ajout d'une ci (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
bachrc authored Oct 14, 2024
1 parent 91ed878 commit acc65a4
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 12 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/deploy-database.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Déploiement de la base de données

on:
push:
branches:
- main
paths:
- pb_migrations/**

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

permissions:
contents: read
id-token: write

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read # required for publishing Docker images
packages: write # required for pushing Docker images

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to the Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
target: database
tags: database:latest
platforms: linux/amd64,linux/arm64/v8
45 changes: 45 additions & 0 deletions .github/workflows/deploy-website.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Déploiement du site

on:
push:
branches:
- main

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

permissions:
contents: read
id-token: write

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read # required for publishing Docker images
packages: write # required for pushing Docker images

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to the Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
target: app
tags: app:latest
platforms: linux/amd64,linux/arm64/v8
30 changes: 25 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
FROM denoland/deno:2.0.0 AS base

FROM base AS dev
ARG PB_VERSION=0.22.21
ARG ARCH=arm64

USER root
RUN mkdir -p /home/deno && chown -R deno:deno /home/deno
RUN apt update && apt install -y git sudo
RUN apt update && apt install -y git sudo unzip
RUN echo "deno ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

USER deno
RUN mkdir -p /home/deno/.local/bin
ENV PATH=$PATH:/home/deno/.local/bin
COPY --from=elestio/pocketbase --chown=deno:deno /usr/local/bin/pocketbase /home/deno/.local/bin/pocketbase
# download and unzip PocketBase
RUN mkdir -p /home/deno/.local/pb
ENV PATH=$PATH:/home/deno/.local/pb
ADD --chown=deno:deno https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_${ARCH}.zip /tmp/pb.zip
RUN unzip /tmp/pb.zip -d /home/deno/.local/pb/

FROM base AS build
WORKDIR /app
USER deno
COPY --chown=deno:deno package.json deno.lock .
RUN deno install --allow-scripts
COPY --chown=deno:deno . .
RUN deno task build

FROM base AS database
WORKDIR /app
COPY ./pb_migrations /app/pb_migrations
CMD "pocketbase serve"

FROM nginx:1-alpine AS app
COPY --from=build /app/build /usr/share/nginx/html
3 changes: 2 additions & 1 deletion src/lib/database.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PocketBase from 'pocketbase';
import { PUBLIC_POCKETBASE_URL } from '$env/static/public';

export const pb = new PocketBase('http://127.0.0.1:8090');
export const pb = new PocketBase(PUBLIC_POCKETBASE_URL);
9 changes: 3 additions & 6 deletions src/routes/profil/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
<script lang="ts">
import { pb } from '$lib/database';
import { currentUser } from '$lib/login.svelte';
pb.collection('users').authRefresh();
</script>

<div class="p-2">
<h1 class="text-2xl">Profil</h1>
<div class="flex flex-col gap-4">
<div class="flex flex-col">
<span class="text-xs font-bold">Nom</span>
<span>{currentUser.value.name}</span>
<span>{currentUser.value?.name}</span>
</div>
<div class="flex flex-col">
<span class="text-xs font-bold">Pseudonyme</span>
<span>{currentUser.value.username}</span>
<span>{currentUser.value?.username}</span>
</div>
<div class="flex flex-col">
<span class="text-xs font-bold">Adresse mail</span>
<span>{currentUser.value.email}</span>
<span>{currentUser.value?.email}</span>
</div>
</div>
</div>

0 comments on commit acc65a4

Please sign in to comment.