mirror of
https://github.com/UniversityOfHelsinkiCS/ohtuilmo.git
synced 2026-10-12 19:03:41 +03:00
Switch to containerized dev environment
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
FROM registry.access.redhat.com/ubi8/nodejs-12
|
||||
|
||||
USER root
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY package* ./
|
||||
|
||||
RUN npm install
|
||||
|
||||
EXPOSE 3001
|
||||
@@ -5,7 +5,7 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"watch": "cross-env NODE_ENV=development nodemon index.js",
|
||||
"watch:test": "npm run db:recreate && cross-env NODE_ENV=test nodemon index.js",
|
||||
"watch:test": "cross-env NODE_ENV=test nodemon index.js",
|
||||
"start": "cross-env NODE_ENV=production node index.js",
|
||||
"test": "npm run lint",
|
||||
"lint": "eslint .",
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
version: '3'
|
||||
services:
|
||||
db:
|
||||
image: postgres:16-alpine
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
container_name: test-db
|
||||
profiles: [test-setup, cypress]
|
||||
expose:
|
||||
- 5432
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 1s
|
||||
timeout: 10s
|
||||
retries: 60
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile.dev
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- |
|
||||
npm run db:migrate
|
||||
npm run db:seed:all
|
||||
npm run watch:test
|
||||
while ! curl -fsS http://localhost:3001/api >/dev/null; sleep 1; done
|
||||
echo "Test setup is now up!"
|
||||
expose:
|
||||
- 3001
|
||||
volumes:
|
||||
- ./backend:/usr/src/app
|
||||
- /usr/src/app/node_modules
|
||||
environment:
|
||||
- PORT=3001
|
||||
- SECRET=yoursecrethere
|
||||
- EMAIL_ENABLED=false
|
||||
- DATABASE_URL=postgres://postgres:postgres@db:5432/postgres
|
||||
container_name: test-backend
|
||||
profiles: [test-setup, cypress]
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile.dev
|
||||
command: npm run dev
|
||||
ports:
|
||||
- 3002:3000
|
||||
volumes:
|
||||
- ./frontend:/usr/src/app
|
||||
- /usr/src/app/node_modules
|
||||
container_name: test-frontend
|
||||
profiles: [test-setup, cypress]
|
||||
depends_on:
|
||||
- backend
|
||||
- db
|
||||
|
||||
cypress:
|
||||
image: cypress/included:3.8.3
|
||||
container_name: cypress
|
||||
profiles: [cypress]
|
||||
volumes:
|
||||
- ./frontend/e2e:/e2e
|
||||
- ./frontend/cypress.json:/cypress.json
|
||||
environment:
|
||||
- CYPRESS_baseUrl=http://frontend:3000
|
||||
- CYPRESS_VIDEO=false
|
||||
depends_on:
|
||||
- db
|
||||
- backend
|
||||
- frontend
|
||||
@@ -0,0 +1,68 @@
|
||||
version: '3'
|
||||
services:
|
||||
db:
|
||||
image: postgres:16-alpine
|
||||
ports:
|
||||
- 5432:5432
|
||||
volumes:
|
||||
- pg-data:/var/lib/postgresql/data
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
container_name: db
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 1s
|
||||
timeout: 10s
|
||||
retries: 60
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile.dev
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- |
|
||||
npm run db:migrate
|
||||
npm run db:seed:all
|
||||
npm run watch
|
||||
ports:
|
||||
- 3001:3001
|
||||
volumes:
|
||||
- ./backend:/usr/src/app
|
||||
- /usr/src/app/node_modules
|
||||
environment:
|
||||
- PORT=3001
|
||||
- SECRET=yoursecrethere
|
||||
- EMAIL_ENABLED=false
|
||||
- DATABASE_URL=postgres://postgres:postgres@db:5432/postgres
|
||||
container_name: backend
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile.dev
|
||||
command: npm run dev
|
||||
ports:
|
||||
- 3000:3000
|
||||
volumes:
|
||||
- ./frontend:/usr/src/app
|
||||
- /usr/src/app/node_modules
|
||||
container_name: frontend
|
||||
depends_on:
|
||||
- backend
|
||||
- db
|
||||
|
||||
adminer:
|
||||
image: adminer
|
||||
container_name: adminer
|
||||
environment:
|
||||
- ADMINER_DESIGN=galkaev
|
||||
ports:
|
||||
- 8083:8080
|
||||
|
||||
volumes:
|
||||
pg-data:
|
||||
@@ -1,37 +0,0 @@
|
||||
version: '2'
|
||||
services:
|
||||
frontend:
|
||||
# you can put your local image instead of ohtuprojektiilmo/ohtufront if you want
|
||||
image: quay.io/ohtuilmo/frontend:staging
|
||||
build: './frontend'
|
||||
ports:
|
||||
- '7000:3000'
|
||||
depends_on:
|
||||
- backend
|
||||
- db
|
||||
|
||||
backend:
|
||||
image: quay.io/ohtuilmo/backend:staging
|
||||
build: './backend'
|
||||
restart: always
|
||||
ports:
|
||||
- '7001:3001'
|
||||
depends_on:
|
||||
- db
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- PORT=3001
|
||||
- SECRET=yoursecrethere
|
||||
|
||||
db:
|
||||
image: postgres:10.6
|
||||
restart: always
|
||||
ports:
|
||||
- '5432:5432'
|
||||
environment:
|
||||
PGDATA: /data/test
|
||||
volumes:
|
||||
- pg-data:/data/test
|
||||
|
||||
volumes:
|
||||
pg-data:
|
||||
+1
-14
@@ -1,14 +1 @@
|
||||
# Only include files that we need for "npm install",
|
||||
# "react-scripts build" and "serve"!
|
||||
*
|
||||
!public/
|
||||
!src/
|
||||
# react-scripts build runs linter, include eslint configs
|
||||
!.eslintignore
|
||||
!.eslintrc.js
|
||||
!package*.json
|
||||
!index.html
|
||||
!vite.config.js
|
||||
# nice-to-haves I guess?
|
||||
!LICENCE
|
||||
!README.md
|
||||
node_modules
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
FROM registry.access.redhat.com/ubi9/nodejs-20
|
||||
|
||||
USER root
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY package* ./
|
||||
|
||||
RUN npm install
|
||||
|
||||
EXPOSE 3000
|
||||
+6
-10
@@ -25,17 +25,13 @@
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"test": "CYPRESS_baseUrl=http://localhost:3000 npm run cypress:open",
|
||||
"test-setup:up": "docker compose -p ohtuilmo-local-test -f ../compose.local-test.yaml --profile test-setup up -d",
|
||||
"test-setup:down": "docker compose -p ohtuilmo-local-test down",
|
||||
"test-setup:restart": "npm run test-setup:down && npm run test-setup:up",
|
||||
"test": "CYPRESS_baseUrl=http://localhost:3002 npx cypress open",
|
||||
"test:headless": "CYPRESS_VIDEO=false CYPRESS_baseUrl=http://localhost:3002 npx cypress run",
|
||||
"lint": "eslint src/",
|
||||
"lint:fix": "eslint --fix src/",
|
||||
"test:headless": "CYPRESS_baseUrl=http://localhost:3000 npm run cypress:run",
|
||||
"e2e:install": "./e2e/run_cypress_e2e.sh install",
|
||||
"e2e:setup": "./e2e/run_cypress_e2e.sh setup",
|
||||
"e2e:run": "./e2e/run_cypress_e2e.sh run",
|
||||
"e2e:open": "./e2e/run_cypress_e2e.sh open",
|
||||
"e2e:teardown": "./e2e/run_cypress_e2e.sh teardown",
|
||||
"cypress:open": "npx cypress open -P ./",
|
||||
"cypress:run": "npx cypress run -P ./"
|
||||
"lint:fix": "eslint --fix src/"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.2.66",
|
||||
|
||||
Regular → Executable
+2
-1
@@ -7,10 +7,11 @@ export default defineConfig(({ command }) => {
|
||||
return {
|
||||
base: '/',
|
||||
server: {
|
||||
host: true,
|
||||
port: 3000,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:3001',
|
||||
target: 'http://backend:3001',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user