mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
dockerfile, docker-compose and nginx
This commit is contained in:
parent
ea462267aa
commit
40f2dcc85c
98
admin/Dockerfile
Normal file
98
admin/Dockerfile
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
##################################################################################
|
||||||
|
# BASE ###########################################################################
|
||||||
|
##################################################################################
|
||||||
|
FROM node:12.19.0-alpine3.10 as base
|
||||||
|
|
||||||
|
# ENVs (available in production aswell, can be overwritten by commandline or env file)
|
||||||
|
## DOCKER_WORKDIR would be a classical ARG, but that is not multi layer persistent - shame
|
||||||
|
ENV DOCKER_WORKDIR="/app"
|
||||||
|
## We Cannot do `$(date -u +'%Y-%m-%dT%H:%M:%SZ')` here so we use unix timestamp=0
|
||||||
|
ENV BUILD_DATE="1970-01-01T00:00:00.00Z"
|
||||||
|
## We cannot do $(npm run version).${BUILD_NUMBER} here so we default to 0.0.0.0
|
||||||
|
ENV BUILD_VERSION="0.0.0.0"
|
||||||
|
## We cannot do `$(git rev-parse --short HEAD)` here so we default to 0000000
|
||||||
|
ENV BUILD_COMMIT="0000000"
|
||||||
|
## SET NODE_ENV
|
||||||
|
ENV NODE_ENV="production"
|
||||||
|
## App relevant Envs
|
||||||
|
ENV PORT="8080"
|
||||||
|
|
||||||
|
# Labels
|
||||||
|
LABEL org.label-schema.build-date="${BUILD_DATE}"
|
||||||
|
LABEL org.label-schema.name="gradido:admin"
|
||||||
|
LABEL org.label-schema.description="Gradido Vue Admin Interface"
|
||||||
|
LABEL org.label-schema.usage="https://github.com/gradido/gradido/admin/README.md"
|
||||||
|
LABEL org.label-schema.url="https://gradido.net"
|
||||||
|
LABEL org.label-schema.vcs-url="https://github.com/gradido/gradido/backend"
|
||||||
|
LABEL org.label-schema.vcs-ref="${BUILD_COMMIT}"
|
||||||
|
LABEL org.label-schema.vendor="gradido Community"
|
||||||
|
LABEL org.label-schema.version="${BUILD_VERSION}"
|
||||||
|
LABEL org.label-schema.schema-version="1.0"
|
||||||
|
LABEL maintainer="support@ogradido.net"
|
||||||
|
|
||||||
|
# Install Additional Software
|
||||||
|
## install: git
|
||||||
|
#RUN apk --no-cache add git
|
||||||
|
|
||||||
|
# Settings
|
||||||
|
## Expose Container Port
|
||||||
|
EXPOSE ${PORT}
|
||||||
|
|
||||||
|
## Workdir
|
||||||
|
RUN mkdir -p ${DOCKER_WORKDIR}
|
||||||
|
WORKDIR ${DOCKER_WORKDIR}
|
||||||
|
|
||||||
|
##################################################################################
|
||||||
|
# DEVELOPMENT (Connected to the local environment, to reload on demand) ##########
|
||||||
|
##################################################################################
|
||||||
|
FROM base as development
|
||||||
|
|
||||||
|
# We don't need to copy or build anything since we gonna bind to the
|
||||||
|
# local filesystem which will need a rebuild anyway
|
||||||
|
|
||||||
|
# Run command
|
||||||
|
# (for development we need to execute yarn install since the
|
||||||
|
# node_modules are on another volume and need updating)
|
||||||
|
CMD /bin/sh -c "yarn install && yarn run dev"
|
||||||
|
|
||||||
|
##################################################################################
|
||||||
|
# BUILD (Does contain all files and is therefore bloated) ########################
|
||||||
|
##################################################################################
|
||||||
|
FROM base as build
|
||||||
|
|
||||||
|
# Copy everything
|
||||||
|
COPY . .
|
||||||
|
# yarn install
|
||||||
|
RUN yarn install --production=false --frozen-lockfile --non-interactive
|
||||||
|
# yarn build
|
||||||
|
RUN yarn run build
|
||||||
|
|
||||||
|
##################################################################################
|
||||||
|
# TEST ###########################################################################
|
||||||
|
##################################################################################
|
||||||
|
FROM build as test
|
||||||
|
|
||||||
|
# Install Additional Software
|
||||||
|
RUN apk add --no-cache bash jq
|
||||||
|
|
||||||
|
# Run command
|
||||||
|
CMD /bin/sh -c "yarn run dev"
|
||||||
|
|
||||||
|
##################################################################################
|
||||||
|
# PRODUCTION (Does contain only "binary"- and static-files to reduce image size) #
|
||||||
|
##################################################################################
|
||||||
|
FROM base as production
|
||||||
|
|
||||||
|
# Copy "binary"-files from build image
|
||||||
|
COPY --from=build ${DOCKER_WORKDIR}/dist ./dist
|
||||||
|
# We also copy the node_modules express and serve-static for the run script
|
||||||
|
COPY --from=build ${DOCKER_WORKDIR}/node_modules ./node_modules
|
||||||
|
# Copy static files
|
||||||
|
COPY --from=build ${DOCKER_WORKDIR}/public ./public
|
||||||
|
# Copy package.json for script definitions (lock file should not be needed)
|
||||||
|
COPY --from=build ${DOCKER_WORKDIR}/package.json ./package.json
|
||||||
|
# Copy run scripts run/
|
||||||
|
COPY --from=build ${DOCKER_WORKDIR}/run ./run
|
||||||
|
|
||||||
|
# Run command
|
||||||
|
CMD /bin/sh -c "yarn run start"
|
||||||
@ -7,7 +7,9 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": false,
|
"private": false,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"start": "node run/server.js",
|
||||||
|
"serve": "vue-cli-service serve --open",
|
||||||
|
"dev": "yarn run serve",
|
||||||
"build": "vue-cli-service build",
|
"build": "vue-cli-service build",
|
||||||
"lint": "vue-cli-service lint"
|
"lint": "vue-cli-service lint"
|
||||||
},
|
},
|
||||||
|
|||||||
15
admin/run/server.js
Normal file
15
admin/run/server.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Imports
|
||||||
|
const express = require('express')
|
||||||
|
const serveStatic = require('serve-static')
|
||||||
|
|
||||||
|
// Port
|
||||||
|
const port = process.env.PORT || 8080
|
||||||
|
|
||||||
|
// Express Server
|
||||||
|
const app = express()
|
||||||
|
// eslint-disable-next-line node/no-path-concat
|
||||||
|
app.use(serveStatic(__dirname + '/../dist'))
|
||||||
|
app.listen(port)
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`http://admin:${port} server started.`)
|
||||||
@ -20,6 +20,25 @@ services:
|
|||||||
# bind the local folder to the docker to allow live reload
|
# bind the local folder to the docker to allow live reload
|
||||||
- ./frontend:/app
|
- ./frontend:/app
|
||||||
|
|
||||||
|
########################################################
|
||||||
|
# ADMIN INTERFACE ######################################
|
||||||
|
########################################################
|
||||||
|
admin:
|
||||||
|
image: gradido/admin:development
|
||||||
|
build:
|
||||||
|
target: development
|
||||||
|
networks:
|
||||||
|
- external-net
|
||||||
|
environment:
|
||||||
|
- NODE_ENV="development"
|
||||||
|
# - DEBUG=true
|
||||||
|
volumes:
|
||||||
|
# This makes sure the docker container has its own node modules.
|
||||||
|
# Therefore it is possible to have a different node version on the host machine
|
||||||
|
- admin_node_modules:/app/node_modules
|
||||||
|
# bind the local folder to the docker to allow live reload
|
||||||
|
- ./admin:/app
|
||||||
|
|
||||||
########################################################
|
########################################################
|
||||||
# BACKEND ##############################################
|
# BACKEND ##############################################
|
||||||
########################################################
|
########################################################
|
||||||
@ -154,6 +173,7 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
frontend_node_modules:
|
frontend_node_modules:
|
||||||
|
admin_node_modules:
|
||||||
backend_node_modules:
|
backend_node_modules:
|
||||||
backend_database_node_modules:
|
backend_database_node_modules:
|
||||||
backend_database_build:
|
backend_database_build:
|
||||||
|
|||||||
@ -30,6 +30,30 @@ services:
|
|||||||
# - ./.env
|
# - ./.env
|
||||||
# - ./frontend/.env
|
# - ./frontend/.env
|
||||||
|
|
||||||
|
########################################################
|
||||||
|
# ADMIN INTERFACE ######################################
|
||||||
|
########################################################
|
||||||
|
admin:
|
||||||
|
image: gradido/admin:latest
|
||||||
|
build:
|
||||||
|
context: ./admin
|
||||||
|
target: production
|
||||||
|
networks:
|
||||||
|
- internal-net
|
||||||
|
ports:
|
||||||
|
- 8080:8080
|
||||||
|
environment:
|
||||||
|
# Envs used in Dockerfile
|
||||||
|
# - DOCKER_WORKDIR="/app"
|
||||||
|
# - PORT=8090
|
||||||
|
# - BUILD_DATE="1970-01-01T00:00:00.00Z"
|
||||||
|
# - BUILD_VERSION="0.0.0.0"
|
||||||
|
# - BUILD_COMMIT="0000000"
|
||||||
|
- NODE_ENV="production"
|
||||||
|
# env_file:
|
||||||
|
# - ./.env
|
||||||
|
# - ./frontend/.env
|
||||||
|
|
||||||
#########################################################
|
#########################################################
|
||||||
## MARIADB ##############################################
|
## MARIADB ##############################################
|
||||||
#########################################################
|
#########################################################
|
||||||
|
|||||||
@ -69,7 +69,19 @@ server {
|
|||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /sockjs-node {
|
location /admin {
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection 'upgrade';
|
||||||
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
|
||||||
|
proxy_pass http://admin:8080;
|
||||||
|
proxy_redirect off;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /sockjs-node {
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection 'upgrade';
|
proxy_set_header Connection 'upgrade';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user