Skip to content

Commit

Permalink
Build docker image for frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-morvan committed Jan 21, 2025
1 parent c881570 commit 6d1a99d
Show file tree
Hide file tree
Showing 6 changed files with 295 additions and 744 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,10 @@ jobs:
- name: Build
working-directory: ./frontend
run: npm run build

build:
runs-on: ubuntu-22.04
name: Build Docker images
steps:
- name: Build
run: docker compose build
13 changes: 12 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@ include:
- georchestra/geor-compose.override.yml

services:
maelstro-front:
build:
context: ./frontend
target: server
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080"]
interval: 10s
retries: 5
start_period: 10s
timeout: 10s

maelstro-back:
build:
context: ./backend
target: server
volumes:
- ./backend:/app
healthcheck:
test: "poetry run health_check"
test: "health_check"
interval: 10s
retries: 5
start_period: 10s
Expand Down
1 change: 1 addition & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
20 changes: 20 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Inspired from https://cli.vuejs.org/guide/deployment.html#docker-nginx

FROM node:22 AS builder

WORKDIR /app

COPY package.json package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
npm install

COPY ./ .
RUN npm run build


FROM nginx AS server

RUN mkdir /app

COPY --from=builder /app/dist /app
COPY nginx.conf /etc/nginx/nginx.conf
30 changes: 30 additions & 0 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location / {
root /app;
index index.html;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
Loading

0 comments on commit 6d1a99d

Please sign in to comment.