Skip to content

Commit

Permalink
add the docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophie committed Mar 16, 2023
1 parent 83dc178 commit 7bf386a
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 30 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,15 @@ If you are a **facilitator**, go to [server/](./server/README.md) and find out h
Have fun :D

## People running Extreme Carpaccio

- Find out what people are saying about Extreme Carpaccio on [Twitter](https://twitter.com/search?vertical=default&q=%22extreme%20carpaccio%22%20OR%20%22Xtreme%20carpaccio%22%20OR%20%23ExtremeCarpaccio&src=typd)

cypress11:
image: cypress/included:cypress-12.5.1-node-16.18.1-chrome-110.0.5481.96-1-ff-109.0-edge-110.0.1587.41-1
entrypoint: /bin/sh -c "cd ./apps/frontend && npm install esbuild-wasm && CYPRESS_BASE_URL=<http://127.0.0.1> cypress run --headless --browser chrome"
depends_on:
- front
working_dir: /test
volumes:
- ./:/test
- /tmp/.X11-unix:/tmp/.X11-unix
48 changes: 48 additions & 0 deletions server/.docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
server {
listen 80;
server_name localhost;

gzip on;
gzip_disable "msie6";

gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;

root /usr/share/nginx/html;

location / {
try_files $uri /index.html;
add_header Cache-Control "no-store, no-cache, must-revalidate";
add_header Pragma "no-cache";
add_header Referrer-Policy origin-when-cross-origin;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
add_header X-XSS-Protection "1; mode=block";
expires -1;
}

# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}

# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}

# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
2 changes: 2 additions & 0 deletions server/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.turbo
17 changes: 17 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:18.15.0-alpine3.17 AS builder

RUN apk add --no-cache libc6-compat

WORKDIR /app

# First install the dependencies (as they change less often)
COPY . .
RUN npm ci
RUN npx turbo prune --scope=frontend --docker

# Build the project
RUN npx turbo build --filter=frontend

FROM nginx:latest
COPY .docker/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/apps/frontend/dist/ /usr/share/nginx/html/
5 changes: 5 additions & 0 deletions server/Dockerfile-cypress
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM cypress/included:cypress-12.5.1-node-16.18.1-chrome-110.0.5481.96-1-ff-109.0-edge-110.0.1587.41-1
COPY /apps/frontend /front/
WORKDIR /front
RUN npm install esbuild-wasm
ENTRYPOINT npm run test:e2e:docker
7 changes: 0 additions & 7 deletions server/apps/frontend/Dockerfile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { baseUrl } from './../share-util';
/// <reference types="cypress" />
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
import '@testing-library/cypress/add-commands';

Given(/^I'm a Seller$/, () => {
cy.intercept(
'POST',
'http://localhost:3000/seller',
`${baseUrl}/seller`,

(req) => {
if (req.body.includes('Xavier') || req.body.includes('newPassword')) {
Expand All @@ -17,7 +18,7 @@ Given(/^I'm a Seller$/, () => {
}
}
);
cy.visit('http://localhost:3000/');
cy.visit(baseUrl);
});
When('I write the field {string} {string} with {string}', (_, label, value) => {
cy.get(`[aria-label="your ${label}"]`).type(value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { baseUrl } from './../share-util';
/// <reference types="cypress" />
import { When, Then } from '@badeball/cypress-cucumber-preprocessor';
import '@testing-library/cypress/add-commands';
Expand All @@ -23,7 +24,7 @@ const checkTableSellers = (table) => {
};

When('There are 3 sellers', () => {
cy.intercept('GET', 'http://localhost:3000/sellers', {
cy.intercept('GET', `${baseUrl}/sellers`, {
statusCode: 200,
body: [
{ cash: 60, name: 'Lukasz', online: true },
Expand All @@ -38,7 +39,7 @@ Then('I see sellers:', (table) => {
});

Then('there is a updating of sellers', () => {
cy.intercept('GET', 'http://localhost:3000/sellers', {
cy.intercept('GET', `${baseUrl}/sellers`, {
statusCode: 200,
body: [
{ cash: 10000023210, name: 'Lukasz', online: true },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { baseUrl } from './../share-util';
/// <reference types="cypress" />
import { When } from '@badeball/cypress-cucumber-preprocessor';
import '@testing-library/cypress/add-commands';

let number = 100;

When('There are 100 iterations', () => {
cy.intercept('GET', 'http://localhost:3000/sellers/history?chunk=10', {
cy.intercept('GET', `${baseUrl}/sellers/history?chunk=10`, {
statusCode: 200,
body: {
lastIteration: 100,
Expand All @@ -20,7 +21,7 @@ When('There are 100 iterations', () => {
});

When('There are 200 iterations', () => {
cy.intercept('GET', 'http://localhost:3000/sellers/history?chunk=10', {
cy.intercept('GET', `${baseUrl}/sellers/history?chunk=10`, {
statusCode: 200,
body: {
lastIteration: 100,
Expand Down
2 changes: 1 addition & 1 deletion server/apps/frontend/cypress/e2e/share-util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Given } from '@badeball/cypress-cucumber-preprocessor';

export const baseUrl = 'http://localhost:3000/';
export const baseUrl = Cypress.config().baseUrl;

Given(/^I'm on the website$/, () => {
cy.get('html').invoke('css', 'height', 'initial');
Expand Down
15 changes: 0 additions & 15 deletions server/apps/frontend/docker-compose.yml

This file was deleted.

3 changes: 2 additions & 1 deletion server/apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"dev": "vite build --watch",
"build": "vite build",
"start:server:local": "vite",
"test:e2e": "cypress run --browser chrome",
"test:e2e:docker": "cypress run --config baseUrl=http://127.0.0.1 --headless --browser chrome",
"test:e2e": "cypress run --headless --browser chrome",
"test": "vitest",
"format:check": "prettier --list-different src",
"format:fix": "prettier --write src",
Expand Down
14 changes: 14 additions & 0 deletions server/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.6'
services:
front:
build: ./
restart: always
ports:
- '80:80'
cypress:
build:
context: .
dockerfile: Dockerfile-cypress
depends_on:
- front
network_mode: 'host'

0 comments on commit 7bf386a

Please sign in to comment.