Commit d314e025 authored by Johan-Henrik Fylling's avatar Johan-Henrik Fylling
Browse files

Add development configuration using bind volumes and nodemon for auto reload upon code change.

parent 392cf691
Pipeline #111203 passed with stages
in 29 seconds
version: '3'
services:
backend:
container_name: django_group_${GROUPID}
build:
context: backend/secfit/
dockerfile: Dockerfile
args:
DJANGO_SUPERUSER_USERNAME: "${DJANGO_SUPERUSER_USERNAME}"
DJANGO_SUPERUSER_PASSWORD: "${DJANGO_SUPERUSER_PASSWORD}"
DJANGO_SUPERUSER_EMAIL: "${DJANGO_SUPERUSER_EMAIL}"
environment:
- GROUPID=${GROUPID}
networks:
backend_bridge:
ipv4_address: 10.${GROUPID}.0.4
application:
container_name: node_group_${GROUPID}
build:
context: frontend/
dockerfile: Dockerfile.dev
args:
GROUPID: ${GROUPID}
DOMAIN: ${DOMAIN}
URL_PREFIX: ${URL_PREFIX}
PORT_PREFIX: ${PORT_PREFIX}
networks:
backend_bridge:
ipv4_address: 10.${GROUPID}.0.5
volumes:
- ./frontend:/app/
- nodemodules:/app/node_modules
web:
container_name: nginx_group_${GROUPID}
build:
context: .
dockerfile: Dockerfile
ports:
- ${PORT_PREFIX}${GROUPID}:80
environment:
- GROUPID=${GROUPID}
- PORT_PREFIX=${PORT_PREFIX}
networks:
backend_bridge:
ipv4_address: 10.${GROUPID}.0.6
networks:
backend_bridge:
driver: bridge
ipam:
config:
- subnet: 10.${GROUPID}.0.0/18
volumes:
nodemodules: {}
# Get docker image
FROM johanhef/secfit_frontend_base:v2
# FROM debian:buster-slim
# Import groupid and host environment variable
ARG GROUPID
ARG DOMAIN
ARG URL_PREFIX
ARG PORT_PREFIX
# Set working dir
WORKDIR /app
# Transfer all our stuff to the builder
COPY . /app/
# Set the host variable in default.js (overwrite)
RUN echo "const HOST = 'http://backend:8000';" > ./www/scripts/defaults.js
# Install cordova
# Also install shelljs because of windows for some reason
# RUN apt-get update -y && apt-get install npm -y && npm install -g cordova && npm install shelljs
# RUN apt-get install -y curl
# RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs
RUN npm install express && npm install -g nodemon
RUN npm install -g nodemon
# Run cordova app
CMD [ "nodemon", "devServer.js"]
const express = require("express");
const app = express();
app.use(express.static("www"));
app.listen(3000, () => {
console.log("Started development server. At http://backend:3000");
})
\ No newline at end of file
{
"ext": "js,html,json"
}
\ No newline at end of file
This diff is collapsed.
{ {
"name": "io.cordova.hellocordova", "name": "io.cordova.hellocordova",
"displayName": "HelloCordova", "displayName": "Secfit",
"version": "1.0.0", "version": "1.0.1",
"description": "A sample Apache Cordova application that responds to the deviceready event.", "description": "An app for school purposes",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "jest" "test": "jest",
"dev": "nodemon devServer.js"
}, },
"keywords": [ "keywords": [
"ecosystem:cordova" "ecosystem:cordova"
], ],
"author": "Apache Cordova Team", "author": "Apache Cordova Team",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": { "devDependencies": {
"cordova-android": "^9.0.0", "cordova-android": "^9.0.0",
"cordova-browser": "^6.0.0", "cordova-browser": "^6.0.0",
...@@ -19,6 +23,7 @@ ...@@ -19,6 +23,7 @@
"cordova-plugin-file": "^6.0.2", "cordova-plugin-file": "^6.0.2",
"cordova-plugin-whitelist": "^1.3.4", "cordova-plugin-whitelist": "^1.3.4",
"jest": "^26.6.3", "jest": "^26.6.3",
"nodemon": "^2.0.7",
"whatwg-fetch": "^3.6.1" "whatwg-fetch": "^3.6.1"
}, },
"cordova": { "cordova": {
......
docker-compose -f docker-compose.dev.yml -p dev build
docker-compose -f docker-compose.dev.yml -p dev up
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment