Compare commits
2 Commits
5a49f5beda
...
28f47a933a
Author | SHA1 | Date | |
---|---|---|---|
28f47a933a | |||
4caafb8c55 |
53
.github/workflows/build_docker.yml
vendored
Normal file
53
.github/workflows/build_docker.yml
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
name: Build Docker Image # nom du workflow
|
||||||
|
|
||||||
|
on: #declancheur
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '*'
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run: #jobs ID (nom du jobs)
|
||||||
|
runs-on: ubuntu-latest # environement de run
|
||||||
|
|
||||||
|
steps: # liste des étapes
|
||||||
|
- name: Checkout # rapatrie le depot
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
git.lab-ouest.org/Epitech/ratrapage_T-WEB
|
||||||
|
tags: |
|
||||||
|
type=edge
|
||||||
|
type=ref,event=pr
|
||||||
|
type=ref,event=branch
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
type=semver,pattern=latest
|
||||||
|
|
||||||
|
- name: Login to Gitea
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: git.lab-ouest.org
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_TOKEN }}
|
||||||
|
|
||||||
|
# - name: Set up Docker Buildx
|
||||||
|
# uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
file: ./Dockerfile
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
64
front/Dockerfile
Normal file
64
front/Dockerfile
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
# This Dockerfile allows you to run AstroJS in server mode
|
||||||
|
|
||||||
|
#########
|
||||||
|
# Build #
|
||||||
|
#########
|
||||||
|
FROM docker.io/node:20-alpine as BUILD_IMAGE
|
||||||
|
|
||||||
|
# Disable telemetry
|
||||||
|
ENV ASTRO_TELEMETRY_DISABLED=1
|
||||||
|
|
||||||
|
# External deps (for node-gyp add: "python3 make g++")
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
|
||||||
|
# run as non root user
|
||||||
|
USER node
|
||||||
|
|
||||||
|
# go to user repository
|
||||||
|
WORKDIR /home/node
|
||||||
|
|
||||||
|
# Add package json
|
||||||
|
ADD --chown=node:node package.json package-lock.json ./
|
||||||
|
|
||||||
|
# install dependencies from package lock
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
# Add project files
|
||||||
|
ADD --chown=node:node . .
|
||||||
|
|
||||||
|
# build
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# remove dev deps
|
||||||
|
RUN npm prune --omit=dev
|
||||||
|
|
||||||
|
##############
|
||||||
|
# Production #
|
||||||
|
##############
|
||||||
|
FROM docker.io/node:20-alpine as PROD_IMAGE
|
||||||
|
|
||||||
|
# inform software to be in production
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV HOST=0.0.0.0
|
||||||
|
ENV RESOURCES_FOLDER=/home/node/.loop/uploads
|
||||||
|
ENV ASTRO_TELEMETRY_DISABLED=1
|
||||||
|
|
||||||
|
# run as non root user
|
||||||
|
USER node
|
||||||
|
|
||||||
|
# go to work folder
|
||||||
|
WORKDIR /home/node
|
||||||
|
|
||||||
|
# Expose port
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
# Add Healthcheck
|
||||||
|
HEALTHCHECK --interval=10s --timeout=10s --start-period=5s --retries=3 CMD wget --no-verbose --tries=1 --spider http://localhost:3000 || exit 1
|
||||||
|
|
||||||
|
# copy from build image
|
||||||
|
COPY --chown=node:node --from=BUILD_IMAGE /home/node/node_modules ./node_modules
|
||||||
|
COPY --chown=node:node --from=BUILD_IMAGE /home/node/dist ./dist
|
||||||
|
COPY --chown=node:node --from=BUILD_IMAGE /home/node/package.json /home/node/.env* ./
|
||||||
|
|
||||||
|
# run it !
|
||||||
|
CMD ["npm", "run", "start"]
|
Loading…
x
Reference in New Issue
Block a user