generated from codegouvfr/eleventy-dsfr
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(docker): dockerisation et publication sur ghcr
- Loading branch information
Showing
7 changed files
with
5,025 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#---------------------------------------------------------------------- | ||
# cartesgouvfr-documentation : Génération d'un build statique | ||
#---------------------------------------------------------------------- | ||
FROM node:18-alpine as builder | ||
|
||
RUN apk add git | ||
|
||
WORKDIR /app | ||
COPY . . | ||
RUN npm ci \ | ||
&& npx @11ty/eleventy \ | ||
&& rm -rf node_modules .git | ||
|
||
#---------------------------------------------------------------------- | ||
# cartesgouvfr-documentation : Config d'un serveur statique avec nginx | ||
#---------------------------------------------------------------------- | ||
FROM nginx:alpine | ||
COPY --from=builder /app/_site /usr/share/nginx/html/ | ||
COPY .docker/nginx.conf /etc/nginx/nginx.conf | ||
|
||
EXPOSE 8082 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
worker_processes 1; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
include mime.types; | ||
default_type application/octet-stream; | ||
|
||
sendfile on; | ||
keepalive_timeout 65; | ||
|
||
server { | ||
listen 8082; | ||
listen [::]:8082; | ||
server_name localhost; | ||
resolver 127.0.0.11; | ||
autoindex off; | ||
|
||
server_name _; | ||
server_tokens off; | ||
|
||
root /usr/share/nginx/html; # Path to your static files | ||
gzip_static on; | ||
|
||
index index.html index.htm; | ||
|
||
# Redirect "/" to "/fr" | ||
location = / { | ||
return 301 /fr; | ||
} | ||
|
||
# Serve static files | ||
location / { | ||
root /usr/share/nginx/html; | ||
index index.html index.htm; | ||
try_files $uri $uri/ /404.html; | ||
} | ||
|
||
# Handle 404 errors | ||
error_page 404 /404.html; | ||
location = /404.html { | ||
root /usr/share/nginx/html; | ||
internal; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/.vscode | ||
/node_modules/ | ||
/docs | ||
/_site | ||
|
||
compose*.yml | ||
renovate.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Docker build & publish | ||
|
||
on: | ||
push: | ||
# Publish semver tags as releases. | ||
tags: ["v*.*.*"] | ||
|
||
env: | ||
# Use docker.io for Docker Hub if empty | ||
REGISTRY: ghcr.io | ||
# github.repository as <account>/<repo> | ||
IMAGE_NAME: ${{ github.repository }} | ||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
|
||
jobs: | ||
deploy-ghcr: | ||
name: Deploy to ghcr | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
needs: build | ||
|
||
steps: | ||
- name: Setup Docker buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
# Login against a Docker registry | ||
# https://github.com/docker/login-action | ||
- name: Log into registry ${{ env.REGISTRY }} | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Extract metadata (tags, labels) for Docker | ||
# https://github.com/docker/metadata-action | ||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
# Build and push Docker image with Buildx | ||
# https://github.com/docker/build-push-action | ||
- name: Build and push Docker image to ghcr | ||
id: build-and-push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: .docker/Dockerfile | ||
pull: true | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: "3.8" | ||
|
||
services: | ||
site: | ||
image: ignf/cartes.gouv.fr-documentation | ||
build: | ||
context: . | ||
dockerfile: ".docker/Dockerfile" | ||
args: | ||
- HTTP_PROXY | ||
- HTTPS_PROXY | ||
ports: | ||
- 8082:8082 | ||
environment: | ||
- HTTP_PROXY=${HTTP_PROXY} | ||
- HTTPS_PROXY=${HTTPS_PROXY} | ||
- http_proxy=${HTTP_PROXY} | ||
- https_proxy=${HTTPS_PROXY} | ||
restart: unless-stopped |
Oops, something went wrong.