Skip to content

Commit

Permalink
Merge pull request #26 from Georiviere/feat_add_ci_installation
Browse files Browse the repository at this point in the history
Feat add ci installation
  • Loading branch information
LePetitTim authored Aug 3, 2023
2 parents 88cb78b + 1cefcbc commit 2b94258
Show file tree
Hide file tree
Showing 25 changed files with 419 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Install dependencies only when needed
FROM node:18-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat g++ gcc libgcc libstdc++ linux-headers make python3
WORKDIR /app
COPY ../package.json /app/package.json
COPY ../yarn.lock /app/yarn.lock
RUN yarn install --frozen-lockfile

FROM node:18-alpine AS builder
WORKDIR /app
COPY .. .
COPY --from=deps /app/node_modules ./node_modules
RUN yarn build
64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Release docker image

on:
release:
types: [created]

jobs:
release:
runs-on: ubuntu-latest
permissions:
packages: write # required to publish docker image
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

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

- name: Extract metadata (tags, labels) for Docker
id: meta-builder
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/georiviere-public-builder

- name: Build and push Docker image builder
uses: docker/build-push-action@v3
with:
context: .
file: ./.docker/Dockerfile
push: true
tags: ${{ steps.meta-builder.outputs.tags }}
labels: ${{ steps.meta-builder.outputs.labels }}
target: builder

attach_install_release:
runs-on: ubuntu-latest
needs: [ release ]
permissions:
contents: write # required to attach zip to release
if: ${{ github.event_name == 'release' && github.event.action == 'created' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Prepare install.zip
run: |
cd install
mkdir georiviere-public
cp -r * ./georiviere-public 2>/dev/null || :
cp .env.dist ./georiviere-public
zip -r ../install.zip georiviere-public/
- name: Attach zip archive as release binary
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'install.zip'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ yarn-error.log*

# local env files
.env*.local
.env
install/.env

# vercel
.vercel
Expand Down
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Install dependencies only when needed
FROM node:18-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat g++ gcc libgcc libstdc++ linux-headers make python3
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
COPY . .
RUN yarn build
CMD ["yarn", "start"]
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,42 @@ Once your dependencies are installed and the `.env` file and your customization
yarn dev
```

### Start the app for the production
### Start the app for the production

With yarn without docker :

```bash
yarn build
yarn start
```

With docker :
Download `zip archive <https://github.com/Georiviere/Georiviere-admin/releases/latest/download/install.zip>`_
```bash
unzip install.zip
cd georiviere-public
cp .env.dist .env
```
Modify .env as needed and change your translation

Then build your image
```bash
docker compose build
```
Whenever you need to change your translation or the .env. You have to rebuild the image.

Launch the service :
```bash
docker compose up -d
```

Whenever you change the settings or need to relaunch the service :
```bash
docker compose down
docker compose up -d
```


### Process manager

In order to have a more robust solution to serve your node server, our advice is to use [pm2](https://pm2.keymetrics.io/).
Expand Down
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "2.3"
services:
front:
image: georiviere-public-dev
build:
context: .
restart: always
ports:
- "${PORT:-8080}:3000"
env_file:
- .env
volumes:
- ./src:/app/src
- ./translations:/app/translations
- ./public:/app/public
2 changes: 2 additions & 0 deletions install/.env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_API_HOST="<YOUR_API_HOST>"
NEXT_PUBLIC_PORTAL=1
9 changes: 9 additions & 0 deletions install/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARG TAG=latest
FROM ghcr.io/georiviere/georiviere-public/georiviere-public-builder:${TAG}

WORKDIR /app
COPY .env .env
COPY translations translations
RUN yarn build

CMD ["yarn", "start"]
142 changes: 142 additions & 0 deletions install/customization/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"header": {
"logo": {
"src": "/medias/logo.svg"
}
},
"footer": {
"partners": [
{
"src": "https://randonature.parc-haut-jura.fr/medias/logos/logo_pnrhj_dark.png",
"label": "Parc naturel régional du Haut-Jura",
"url": "http://parc-haut-jura.fr/"
},
{
"src": "https://randonature.parc-haut-jura.fr/medias/logos/logo_gtj_dark.png",
"label": "Grandes traversées du Haut-Jura",
"url": "https://www.gtj.asso.fr/"
},
{
"src": "https://randonature.parc-haut-jura.fr/medias/logos/logo_region_aura_dark.png",
"label": "La Région Auvergne-Rhône-Alpes",
"url": "https://www.montagnes-du-jura.fr/"
}
],
"informations": [
{
"name": "Parc naturel régional du Haut-Jura",
"location": [
[
"29 Le Village",
"39310 LAJOUX"
]
],
"phone": [
"03 84 34 12 30"
],
"email": [
"[email protected]"
]
}
],
"links": [
{
"label": "Mentions légales xxxx",
"url": "/page/mentions-legales"
},
{
"label": "Georivière",
"url": "https://georiviere.fr/"
}
],
"socialNetworks": [
{
"label": "Facebook",
"url": "https://www.facebook.com/PNRHJ/",
"icon": "/medias/facebook.svg"
},
{
"label": "YouTube",
"url": "https://www.youtube.com/channel/UC5UbalFTYO8BlYRa9qbZmaQ/",
"icon": "/medias/youtube.svg"
}
]
},
"homepage": {
"welcomeBanner": {
"images": [
{
"url": "/medias/home.jpg"
}
],
"shouldDisplayText": true
},
"introduction": {
"title": "Découvez la démarche",
"images": [
{
"url": "/medias/illustration.jpg"
}
],
"content": "<p class=\"my-8\">sagittis sodales neque. Aenean porttitor nunc vitae nisi fermentum tincidunt. Duis at tellus sed risus rhoncus maximus et ut erat. Vestibulum eu tempus odio, ac commodo justo. Cras eget sem ac elit aliquam scelerisque. Nulla id turpis metus. Fusce vel risus lacinia, lobortis ipsum ut, gravida felis. Donec at sollicitudin mi. Fusce ut nibh at libero feugiat faucibus. Sed maximus justo a tellus consectetur, eget accumsan libero ultrices. Vivamus sagittis faucibus pretium. Donec dui tortor, condimentum eu finibus at, feugiat lacinia lorem.</p><p class=\"my-8\">Sed tristique libero quis posuere luctus. Cras et efficitur nisl. Ut porta, ligula at auctor auctor, arcu sem tempor urna, vel convallis dui dolor quis neque. Fusce id rutrum lectus. Suspendisse potenti. Cras sodales semper bibendum. Praesent et viverra nulla. Nunc viverra ut sapien id ultricies. Fusce mollis venenatis metus, id imperdiet diam congue nec. Mauris suscipit suscipit velit, nec maximus est convallis eleifend. Phasellus a elit velit. Proin maximus, enim et gravida imperdiet, nunc enim elementum est, ut consectetur erat diam vel felis. Quisque feugiat nisl malesuada, fringilla sem non, consectetur nisi.</p>"
},
"suggestions": [
{
"type": "static",
"title": "Connaissances",
"subtitle": "Parcourez les données et actions liées au cours d'eau sur le territoire",
"content": [
{
"label": "Cours d'eau",
"description": "Naviguez sur la carte pour voir les informations détaillées sur les cours d'eau du territoire",
"images": [
{
"thumbnail": "/medias/placeholder0.jpg"
}
],
"href": "/map?layers=8,10,12,14"
},
{
"label": "Connaissances",
"description": "Visualisez l'ensemble des observations réalisées conjointement par le parc et les contributeurs",
"images": [
{
"thumbnail": "/medias/placeholder0.jpg"
}
],
"href": "/map?layers=8,10,11,12,14"
},
{
"label": "Actions",
"description": "Découvez les travaux du parc dans le cadre de la gestion du territoire aquatique (animation à venir, travaux, chantiers participatifs, etc.)",
"images": [
{
"thumbnail": "/medias/placeholder0.jpg"
}
],
"href": "/map?layers=8,10,12,14"
},
{
"label": "Zones sensibles",
"description": "Explorez les zones de protection du biotope et de la biodiversité",
"images": [
{
"thumbnail": "/medias/placeholder0.jpg"
}
],
"href": "/map?layers=8,10,12,13,14"
}
]
},
{
"type": "observation",
"title": "Contributions",
"subtitle": "Citoyen, contribuez à la connaissance des rivières aux côtés des agents du parc"
},
{
"type": "action",
"title": "Dernières contributions"
}
]
}
}
14 changes: 14 additions & 0 deletions install/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: "2.3"
services:
front:
image: georiviere-public
build:
context: .
restart: always
ports:
- "${PORT:-8080}:3000"
env_file:
- .env
volumes:
- "${CUSTOMIZATION_DIRECTORY:-./customization}:/app/src/customization"
- "${MEDIAS_DIRECTORY:-./medias}:/app/public/medias/"
Binary file added install/medias/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions install/medias/facebook.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added install/medias/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added install/medias/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added install/medias/home.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added install/medias/illustration.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions install/medias/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added install/medias/placeholder.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added install/medias/placeholder0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added install/medias/placeholder1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added install/medias/placeholder2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added install/medias/placeholder3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions install/medias/youtube.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2b94258

Please sign in to comment.