mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge pull request #4151 from Ocelot-Social-Community/fix_docker
Rework dockerfiles & docker-compose
This commit is contained in:
commit
5ef781c49d
68
.github/workflows/ci.yml
vendored
68
.github/workflows/ci.yml
vendored
@ -15,32 +15,78 @@ jobs:
|
||||
scripts/translations/sort.sh
|
||||
scripts/translations/missing-keys.sh
|
||||
|
||||
- name: Build neo4j image
|
||||
##########################################################################
|
||||
# NEO4J ##################################################################
|
||||
##########################################################################
|
||||
- name: Neo4J | Build `community` image
|
||||
uses: docker/build-push-action@v1.1.0
|
||||
with:
|
||||
repository: ocelotsocialnetwork/neo4j
|
||||
tags: latest
|
||||
path: neo4j/
|
||||
push: false
|
||||
- name: Build backend base image
|
||||
|
||||
##########################################################################
|
||||
# BACKEND ################################################################
|
||||
##########################################################################
|
||||
# TODO: We want to push this to dockerhub
|
||||
#- name: Build backend production image
|
||||
# uses: docker/build-push-action@v1.1.0
|
||||
# with:
|
||||
# repository: ocelotsocialnetwork/backend
|
||||
# tags: production
|
||||
# target: production
|
||||
# path: backend/
|
||||
# push: false
|
||||
|
||||
# Build Docker Image (build)
|
||||
- name: backend | Build `build` image
|
||||
uses: docker/build-push-action@v1.1.0
|
||||
with:
|
||||
repository: ocelotsocialnetwork/backend
|
||||
tags: build-and-test
|
||||
target: build-and-test
|
||||
tags: build
|
||||
target: build
|
||||
path: backend/
|
||||
push: false
|
||||
- name: Build webapp base image
|
||||
|
||||
# Lint
|
||||
- name: backend | Lint
|
||||
run: docker run --rm ocelotsocialnetwork/backend:build yarn run lint
|
||||
|
||||
# Unit Tests
|
||||
#- name: backend | Unit tests
|
||||
# run: |
|
||||
# docker-compose up
|
||||
# docker-compose exec backend yarn test
|
||||
|
||||
##########################################################################
|
||||
# WEBAPP #################################################################
|
||||
##########################################################################
|
||||
# TODO: We want to push this to dockerhub
|
||||
#- name: Build webapp production image
|
||||
# uses: docker/build-push-action@v1.1.0
|
||||
# with:
|
||||
# repository: ocelotsocialnetwork/webapp
|
||||
# tags: production
|
||||
# target: production
|
||||
# path: webapp/
|
||||
# push: false
|
||||
|
||||
# Build Docker Image (build)
|
||||
- name: webapp | Build `build` image
|
||||
uses: docker/build-push-action@v1.1.0
|
||||
with:
|
||||
repository: ocelotsocialnetwork/webapp
|
||||
tags: build-and-test
|
||||
target: build-and-test
|
||||
tags: build
|
||||
target: build
|
||||
path: webapp/
|
||||
push: false
|
||||
|
||||
- name: Lint backend
|
||||
run: docker run --rm ocelotsocialnetwork/backend:build-and-test yarn run lint
|
||||
- name: Lint webapp
|
||||
run: docker run --rm ocelotsocialnetwork/webapp:build-and-test yarn run lint
|
||||
# Lint
|
||||
- name: webapp | Lint
|
||||
run: docker run --rm ocelotsocialnetwork/webapp:build yarn run lint
|
||||
|
||||
# Unit Tests
|
||||
- name: webapp | Unit tests
|
||||
run: docker run --rm ocelotsocialnetwork/webapp:build yarn run test
|
||||
|
||||
|
||||
100
README.md
100
README.md
@ -1,4 +1,4 @@
|
||||
# Human-Connection
|
||||
# ocelot.social
|
||||
|
||||
[](https://travis-ci.com/Human-Connection/Human-Connection)
|
||||
[](https://codecov.io/gh/Human-Connection/Human-Connection/)
|
||||
@ -6,22 +6,13 @@
|
||||
[](https://discordapp.com/invite/DFSjPaX)
|
||||
[](https://www.codetriage.com/human-connection/human-connection)
|
||||
|
||||
Human Connection is a nonprofit social, action and knowledge network that connects information to action and promotes positive local and global change in all areas of life.
|
||||
ocelot.social is a nonprofit social, action and knowledge network that connects information to action and promotes positive local and global change in all areas of life.
|
||||
|
||||
* **Social**: Interact with other people not just by commenting their posts, but by providing **Pro & Contra** arguments, give a **Versus** or ask them by integrated **Chat** or **Let's Talk**
|
||||
* **Knowledge**: Read articles about interesting topics and find related posts in the **More Info** tab or by **Filtering** based on **Categories** and **Tagging** or by using the **Fulltext Search**.
|
||||
* **Action**: Don't just read about how to make the world a better place, but come into **Action** by following provided suggestions on the **Action** tab provided by other people or **Organisations**.
|
||||
|
||||
[](https://human-connection.org)
|
||||
|
||||
**Technology Stack**
|
||||
|
||||
* [VueJS](https://vuejs.org/)
|
||||
* [NuxtJS](https://nuxtjs.org/)
|
||||
* [GraphQL](https://graphql.org/)
|
||||
* [NodeJS](https://nodejs.org/en/)
|
||||
* [Neo4J](https://neo4j.com/)
|
||||
|
||||
[](https://ocelot.social)
|
||||
|
||||
## Live demo
|
||||
|
||||
@ -35,14 +26,77 @@ Logins:
|
||||
| `moderator@example.org` | 1234 | moderator |
|
||||
| `admin@example.org` | 1234 | admin |
|
||||
|
||||
## Documentation
|
||||
## Directory Layout
|
||||
|
||||
Learn how to set up a local development environment in our [Docs](https://docs.human-connection.org/human-connection/) :mag_right:
|
||||
There are four important directories:
|
||||
* [Backend](./backend) runs on the server and is a middleware between database and frontend
|
||||
* [Frontend](./webapp) is a server-side-rendered and client-side-rendered web frontend
|
||||
* [Deployment](./deployment) configuration for kubernetes
|
||||
* [Cypress](./cypress) contains end-to-end tests and executable feature specifications
|
||||
|
||||
## Translations
|
||||
In order to setup the application and start to develop features you have to
|
||||
setup **frontend** and **backend**.
|
||||
|
||||
You can help translating the interface by joining us on [lokalise.co](https://lokalise.co/public/556252725c18dd752dd546.13222042/).
|
||||
Thank you lokalise for providing us with a premium account :raised_hands:.
|
||||
There are two approaches:
|
||||
|
||||
1. Local installation, which means you have to take care of dependencies yourself
|
||||
2. **Or** Install everything through Docker which takes care of dependencies for you
|
||||
|
||||
## Installation
|
||||
|
||||
### Clone the Repository
|
||||
Clone the repository, this will create a new folder called `Ocelot-Social`:
|
||||
|
||||
Using HTTPS:
|
||||
```bash
|
||||
$ git clone https://github.com/Ocelot-Social-Community/Ocelot-Social.git
|
||||
```
|
||||
|
||||
Using SSH:
|
||||
```bash
|
||||
$ git clone git@github.com:Human-Connection/Human-Connection.git
|
||||
```
|
||||
|
||||
Change into the new folder.
|
||||
|
||||
```bash
|
||||
$ cd Ocelot-Social
|
||||
```
|
||||
|
||||
### Docker Installation
|
||||
|
||||
Docker is a software development container tool that combines software and its dependencies into one standardized unit that contains everything needed to run it. This helps us to avoid problems with dependencies and makes installation easier.
|
||||
|
||||
#### General Installation of Docker
|
||||
|
||||
There are [sevaral ways to install Docker CE](https://docs.docker.com/install/) on your computer or server.
|
||||
|
||||
* [install Docker Desktop on macOS](https://docs.docker.com/docker-for-mac/install/)
|
||||
* [install Docker Desktop on Windows](https://docs.docker.com/docker-for-windows/install/)
|
||||
* [install Docker CE on Linux](https://docs.docker.com/install/)
|
||||
|
||||
Check the correct Docker installation by checking the version before proceeding. E.g. we have the following versions:
|
||||
|
||||
```bash
|
||||
$ docker --version
|
||||
Docker version 18.09.2
|
||||
$ docker-compose --version
|
||||
docker-compose version 1.23.2
|
||||
```
|
||||
|
||||
#### Start Ocelot-Social via Docker-Compose
|
||||
|
||||
For Development:
|
||||
```bash
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
For Production
|
||||
```bash
|
||||
docker-compose -f docker-compose.yml up
|
||||
```
|
||||
|
||||
This will start all required Docker containers
|
||||
|
||||
## Developer Chat
|
||||
|
||||
@ -50,12 +104,16 @@ Join our friendly open-source community on [Discord](https://discordapp.com/invi
|
||||
Just introduce yourself at `#introduce-yourself` and mention `@@Mentor` to get you onboard :neckbeard:
|
||||
Check out the [contribution guideline](./CONTRIBUTING.md), too!
|
||||
|
||||
[](https://sourcerer.io/fame/roschaefer/Human-Connection/Human-Connection/links/0)[](https://sourcerer.io/fame/roschaefer/Human-Connection/Human-Connection/links/1)[](https://sourcerer.io/fame/roschaefer/Human-Connection/Human-Connection/links/2)[](https://sourcerer.io/fame/roschaefer/Human-Connection/Human-Connection/links/3)[](https://sourcerer.io/fame/roschaefer/Human-Connection/Human-Connection/links/4)[](https://sourcerer.io/fame/roschaefer/Human-Connection/Human-Connection/links/5)[](https://sourcerer.io/fame/roschaefer/Human-Connection/Human-Connection/links/6)[](https://sourcerer.io/fame/roschaefer/Human-Connection/Human-Connection/links/7)
|
||||
We give write permissions to every developer who asks for it. Just text us on
|
||||
[Discord](https://discord.gg/6ub73U3).
|
||||
|
||||
## Open-Source Bounties
|
||||
## Technology Stack
|
||||
|
||||
You can get a small financial compensation for your contribution :moneybag: See
|
||||
details in our [Contribution Guidelines](./CONTRIBUTING.md#open-source-bounties).
|
||||
* [VueJS](https://vuejs.org/)
|
||||
* [NuxtJS](https://nuxtjs.org/)
|
||||
* [GraphQL](https://graphql.org/)
|
||||
* [NodeJS](https://nodejs.org/en/)
|
||||
* [Neo4J](https://neo4j.com/)
|
||||
|
||||
## Attributions
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
* [Introduction](README.md)
|
||||
* [Edit this Documentation](edit-this-documentation.md)
|
||||
* [Installation](installation.md)
|
||||
* [Neo4J](neo4j/README.md)
|
||||
* [Backend](backend/README.md)
|
||||
* [GraphQL](backend/graphql.md)
|
||||
|
||||
@ -1,28 +1,87 @@
|
||||
##################################################################################
|
||||
# BASE ###########################################################################
|
||||
##################################################################################
|
||||
FROM node:12.19.0-alpine3.10 as base
|
||||
LABEL Description="Backend of the Social Network ocelot.social" Vendor="ocelot.social Community" Version="0.0.1" Maintainer="ocelot.social Community (devops@ocelot.social)"
|
||||
|
||||
EXPOSE 4000
|
||||
CMD ["yarn", "run", "start"]
|
||||
ARG BUILD_COMMIT
|
||||
ENV BUILD_COMMIT=$BUILD_COMMIT
|
||||
ARG WORKDIR=/develop-backend
|
||||
RUN mkdir -p $WORKDIR
|
||||
WORKDIR $WORKDIR
|
||||
# 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 $(yarn run version) here so we default to 0.0.0
|
||||
## TODO: Missing Build number - do that once we have a CI which actually generates it
|
||||
ENV BUILD_VERSION="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="4000"
|
||||
|
||||
# Labels
|
||||
LABEL org.label-schema.build-date="${BUILD_DATE}"
|
||||
LABEL org.label-schema.name="ocelot.social:backend"
|
||||
LABEL org.label-schema.description="Backend of the Social Network Software ocelot.social"
|
||||
LABEL org.label-schema.usage="https://github.com/Ocelot-Social-Community/Ocelot-Social/blob/master/README.md"
|
||||
LABEL org.label-schema.url="https://ocelot.social"
|
||||
LABEL org.label-schema.vcs-url="https://github.com/Ocelot-Social-Community/Ocelot-Social/tree/master/backend"
|
||||
LABEL org.label-schema.vcs-ref="${BUILD_COMMIT}"
|
||||
LABEL org.label-schema.vendor="ocelot.social Community"
|
||||
LABEL org.label-schema.version="${BUILD_VERSION}"
|
||||
LABEL org.label-schema.schema-version="1.0"
|
||||
LABEL maintainer="devops@ocelot.social"
|
||||
|
||||
# Install Additional Software
|
||||
## install: git
|
||||
RUN apk --no-cache add git
|
||||
|
||||
COPY package.json yarn.lock ./
|
||||
COPY .env.template .env
|
||||
# Settings
|
||||
## Expose Container Port
|
||||
EXPOSE ${PORT}
|
||||
|
||||
FROM base as build-and-test
|
||||
RUN yarn install --production=false --frozen-lockfile --non-interactive
|
||||
## 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 . .
|
||||
RUN NODE_ENV=production yarn run build
|
||||
# yarn install
|
||||
RUN yarn install --production=false --frozen-lockfile --non-interactive
|
||||
# yarn build
|
||||
RUN yarn run build
|
||||
|
||||
# reduce image size with a multistage build
|
||||
##################################################################################
|
||||
# PRODUCTION (Does contain only "binary"- and static-files to reduce image size) #
|
||||
##################################################################################
|
||||
FROM base as production
|
||||
ENV NODE_ENV=production
|
||||
COPY --from=build-and-test /develop-backend/dist ./dist
|
||||
COPY ./public/img/ ./public/img/
|
||||
COPY ./public/providers.json ./public/providers.json
|
||||
RUN yarn install --production=true --frozen-lockfile --non-interactive --no-cache
|
||||
|
||||
# Copy "binary"-files from build image
|
||||
COPY --from=build ${DOCKER_WORKDIR}/dist ./dist
|
||||
COPY --from=build ${DOCKER_WORKDIR}/node_modules ./node_modules
|
||||
# Copy static files
|
||||
# TODO - externalize the uploads so we can copy the whole folder
|
||||
COPY --from=build ${DOCKER_WORKDIR}/public/img/ ./public/img/
|
||||
COPY --from=build ${DOCKER_WORKDIR}/public/providers.json ./public/providers.json
|
||||
# Copy package.json for script definitions (lock file should not be needed)
|
||||
COPY --from=build ${DOCKER_WORKDIR}/package.json ./package.json
|
||||
|
||||
# Run command
|
||||
CMD /bin/sh -c "yarn run start"
|
||||
@ -178,32 +178,20 @@ database after each test, running the tests will wipe out all your data!
|
||||
{% tabs %}
|
||||
{% tab title="Docker" %}
|
||||
|
||||
Run the _**jest**_ tests:
|
||||
Run the unit tests:
|
||||
|
||||
```bash
|
||||
$ docker-compose exec backend yarn run test:jest
|
||||
```
|
||||
|
||||
Run the _**cucumber**_ features:
|
||||
|
||||
```bash
|
||||
$ docker-compose exec backend yarn run test:cucumber
|
||||
$ docker-compose exec backend yarn run test
|
||||
```
|
||||
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Without Docker" %}
|
||||
|
||||
Run the _**jest**_ tests:
|
||||
Run the unit tests:
|
||||
|
||||
```bash
|
||||
$ yarn run test:jest
|
||||
```
|
||||
|
||||
Run the _**cucumber**_ features:
|
||||
|
||||
```bash
|
||||
$ yarn run test:cucumber
|
||||
$ yarn run test
|
||||
```
|
||||
|
||||
{% endtab %}
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
"dev": "nodemon --exec babel-node src/ -e js,gql",
|
||||
"dev:debug": "nodemon --exec babel-node --inspect=0.0.0.0:9229 src/ -e js,gql",
|
||||
"lint": "eslint src --config .eslintrc.js",
|
||||
"test": "jest --forceExit --detectOpenHandles --runInBand",
|
||||
"test": "cross-env NODE_ENV=test jest --forceExit --detectOpenHandles --runInBand",
|
||||
"db:clean": "babel-node src/db/clean.js",
|
||||
"db:reset": "yarn run db:clean",
|
||||
"db:seed": "babel-node src/db/seed.js",
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { handler } from './webfinger'
|
||||
import Factory, { cleanDatabase } from '../../db/factories'
|
||||
import { getDriver } from '../../db/neo4j'
|
||||
import CONFIG from '../../config'
|
||||
|
||||
let resource, res, json, status, contentType
|
||||
|
||||
@ -98,12 +99,12 @@ describe('webfinger', () => {
|
||||
expect(json).toHaveBeenCalledWith({
|
||||
links: [
|
||||
{
|
||||
href: 'http://localhost:3000/activitypub/users/some-user',
|
||||
href: `${CONFIG.CLIENT_URI}/activitypub/users/some-user`,
|
||||
rel: 'self',
|
||||
type: 'application/activity+json',
|
||||
},
|
||||
],
|
||||
subject: 'acct:some-user@localhost:3000',
|
||||
subject: `acct:some-user@${new URL(CONFIG.CLIENT_URI).host}`,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -8,7 +8,7 @@ if (require.resolve) {
|
||||
dotenv.config({ path: require.resolve('../../.env') })
|
||||
} catch (error) {
|
||||
if (error.code !== 'MODULE_NOT_FOUND') throw error
|
||||
console.log('WARN: No `.env` file found in /backend') // eslint-disable-line no-console
|
||||
console.log('WARN: No `.env` file found in `/app` (docker) or `/backend` (no docker)') // eslint-disable-line no-console
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -29,15 +29,25 @@ const onlyYourself = rule({
|
||||
|
||||
const isMyOwn = rule({
|
||||
cache: 'no_cache',
|
||||
})(async (parent, args, context, info) => {
|
||||
return context.user.id === parent.id
|
||||
})(async (parent, args, { user }, info) => {
|
||||
return user && user.id === parent.id
|
||||
})
|
||||
|
||||
const isMySocialMedia = rule({
|
||||
cache: 'no_cache',
|
||||
})(async (_, args, { user }) => {
|
||||
// We need a User
|
||||
if (!user) {
|
||||
return false
|
||||
}
|
||||
let socialMedia = await neode.find('SocialMedia', args.id)
|
||||
socialMedia = await socialMedia.toJson()
|
||||
// Did we find a social media node?
|
||||
if (!socialMedia) {
|
||||
return false
|
||||
}
|
||||
socialMedia = await socialMedia.toJson() // whats this for?
|
||||
|
||||
// Is it my social media entry?
|
||||
return socialMedia.ownedBy.node.id === user.id
|
||||
})
|
||||
|
||||
|
||||
@ -7,13 +7,13 @@ dbInitializion: "yarn prod:migrate init"
|
||||
# dbMigrations runs the database migrations in a post-upgrade hook.
|
||||
dbMigrations: "yarn prod:migrate up"
|
||||
# bakendImage is the docker image for the backend deployment
|
||||
backendImage: ocelotsocialnetwork/develop-backend
|
||||
backendImage: ocelotsocialnetwork/backend
|
||||
# maintenanceImage is the docker image for the maintenance deployment
|
||||
maintenanceImage: ocelotsocialnetwork/develop-maintenance
|
||||
maintenanceImage: ocelotsocialnetwork/maintenance
|
||||
# neo4jImage is the docker image for the neo4j deployment
|
||||
neo4jImage: ocelotsocialnetwork/develop-neo4j
|
||||
neo4jImage: ocelotsocialnetwork/neo4j
|
||||
# webappImage is the docker image for the webapp deployment
|
||||
webappImage: ocelotsocialnetwork/develop-webapp
|
||||
webappImage: ocelotsocialnetwork/webapp
|
||||
# image configures pullPolicy related to the docker images
|
||||
image:
|
||||
# pullPolicy indicates when, if ever, pods pull a new image from docker hub.
|
||||
|
||||
@ -43,13 +43,13 @@ Then temporarily delete backend and database deployments
|
||||
```bash
|
||||
$ kubectl -n ocelot-social get deployments
|
||||
NAME READY UP-TO-DATE AVAILABLE AGE
|
||||
develop-backend 1/1 1 1 3d11h
|
||||
develop-neo4j 1/1 1 1 3d11h
|
||||
develop-webapp 2/2 2 2 73d
|
||||
$ kubectl -n ocelot-social delete deployment develop-neo4j
|
||||
deployment.extensions "develop-neo4j" deleted
|
||||
$ kubectl -n ocelot-social delete deployment develop-backend
|
||||
deployment.extensions "develop-backend" deleted
|
||||
backend 1/1 1 1 3d11h
|
||||
neo4j 1/1 1 1 3d11h
|
||||
webapp 2/2 2 2 73d
|
||||
$ kubectl -n ocelot-social delete deployment neo4j
|
||||
deployment.extensions "neo4j" deleted
|
||||
$ kubectl -n ocelot-social delete deployment backend
|
||||
deployment.extensions "backend" deleted
|
||||
```
|
||||
|
||||
Deploy one-time develop-maintenance-worker pod:
|
||||
|
||||
@ -18,8 +18,8 @@ minikube dashboard, expose the services you want on your host system.
|
||||
For example:
|
||||
|
||||
```text
|
||||
$ minikube service develop-webapp --namespace=ocelotsocialnetwork
|
||||
$ minikube service webapp --namespace=ocelotsocialnetwork
|
||||
# optionally
|
||||
$ minikube service develop-backend --namespace=ocelotsocialnetwork
|
||||
$ minikube service backend --namespace=ocelotsocialnetwork
|
||||
```
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ spec:
|
||||
name: configmap
|
||||
- secretRef:
|
||||
name: ocelot-social
|
||||
image: ocelotsocialnetwork/develop-webapp:latest
|
||||
image: ocelotsocialnetwork/webapp:latest
|
||||
imagePullPolicy: Always
|
||||
name: web
|
||||
ports:
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
version: "3.4"
|
||||
|
||||
services:
|
||||
webapp:
|
||||
environment:
|
||||
- "CI=${CI}"
|
||||
image: ocelotsocialnetwork/develop-webapp:build-and-test
|
||||
build:
|
||||
context: webapp
|
||||
target: build-and-test
|
||||
backend:
|
||||
environment:
|
||||
- "CI=${CI}"
|
||||
image: ocelotsocialnetwork/develop-backend:build-and-test
|
||||
build:
|
||||
context: backend
|
||||
target: build-and-test
|
||||
@ -1,57 +1,68 @@
|
||||
version: "3.4"
|
||||
|
||||
services:
|
||||
########################################################
|
||||
# WEBAPP ###############################################
|
||||
########################################################
|
||||
webapp:
|
||||
image: ocelotsocialnetwork/develop-webapp:build-and-test
|
||||
image: ocelotsocialnetwork/webapp:development
|
||||
build:
|
||||
context: webapp
|
||||
target: build-and-test
|
||||
target: development
|
||||
environment:
|
||||
- NUXT_BUILD=/tmp/nuxt # avoid file permission issues when `rm -rf .nuxt/`
|
||||
- PUBLIC_REGISTRATION=true
|
||||
command: yarn run dev
|
||||
- NODE_ENV="development"
|
||||
# - DEBUG=true
|
||||
# - NUXT_BUILD=/tmp/nuxt # avoid file permission issues when `rm -rf .nuxt/`
|
||||
volumes:
|
||||
- ./webapp:/develop-webapp
|
||||
- webapp_node_modules:/develop-webapp/node_modules
|
||||
# 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
|
||||
- webapp_node_modules:/app/node_modules
|
||||
# bind the local folder to the docker to allow live reload
|
||||
- ./webapp:/app
|
||||
|
||||
########################################################
|
||||
# BACKEND ##############################################
|
||||
########################################################
|
||||
backend:
|
||||
image: ocelotsocialnetwork/develop-backend:build-and-test
|
||||
image: ocelotsocialnetwork/backend:development
|
||||
build:
|
||||
context: backend
|
||||
target: build-and-test
|
||||
command: yarn run dev
|
||||
target: development
|
||||
environment:
|
||||
- SMTP_HOST=mailserver
|
||||
- SMTP_PORT=25
|
||||
- SMTP_IGNORE_TLS=true
|
||||
- "DEBUG=${DEBUG}"
|
||||
- PUBLIC_REGISTRATION=false
|
||||
- NODE_ENV="development"
|
||||
- DEBUG=true
|
||||
volumes:
|
||||
- ./backend:/develop-backend
|
||||
- backend_node_modules:/develop-backend/node_modules
|
||||
- uploads:/develop-backend/public/uploads
|
||||
# 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
|
||||
- backend_node_modules:/app/node_modules
|
||||
# bind the local folder to the docker to allow live reload
|
||||
- ./backend:/app
|
||||
|
||||
########################################################
|
||||
# NEO4J ################################################
|
||||
########################################################
|
||||
neo4j:
|
||||
volumes:
|
||||
- neo4j_data:/data
|
||||
maintenance:
|
||||
image: ocelotsocialnetwork/develop-maintenance:latest
|
||||
build:
|
||||
context: webapp
|
||||
dockerfile: Dockerfile.maintenance
|
||||
networks:
|
||||
- hc-network
|
||||
image: ocelotsocialnetwork/neo4j:development
|
||||
ports:
|
||||
- 3503:80
|
||||
# Also expose the neo4j query browser
|
||||
- 7474:7474
|
||||
networks:
|
||||
# So we can access the neo4j query browser from our host machine
|
||||
- external-net
|
||||
|
||||
########################################################
|
||||
# MAINTENANCE ##########################################
|
||||
########################################################
|
||||
maintenance:
|
||||
image: ocelotsocialnetwork/maintenance:development
|
||||
|
||||
########################################################
|
||||
# MAILSERVER TO FAKE SMTP ##############################
|
||||
########################################################
|
||||
mailserver:
|
||||
image: djfarrelly/maildev
|
||||
ports:
|
||||
- 1080:80
|
||||
networks:
|
||||
- hc-network
|
||||
|
||||
networks:
|
||||
hc-network:
|
||||
- external-net
|
||||
volumes:
|
||||
webapp_node_modules:
|
||||
backend_node_modules:
|
||||
neo4j_data:
|
||||
uploads:
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
version: "3.4"
|
||||
|
||||
services:
|
||||
webapp:
|
||||
build:
|
||||
context: webapp
|
||||
target: production
|
||||
args:
|
||||
- "BUILD_COMMIT=${TRAVIS_COMMIT}"
|
||||
backend:
|
||||
build:
|
||||
context: backend
|
||||
target: production
|
||||
args:
|
||||
- "BUILD_COMMIT=${TRAVIS_COMMIT}"
|
||||
neo4j:
|
||||
build:
|
||||
context: neo4j
|
||||
args:
|
||||
- "BUILD_COMMIT=${TRAVIS_COMMIT}"
|
||||
@ -1,75 +1,117 @@
|
||||
# This file defines the production settings. It is overwritten by docker-compose.override.yml,
|
||||
# which defines the development settings. The override.yml is loaded by default. Therefore it
|
||||
# is required to explicitly define if you want an production build:
|
||||
# > docker-compose -f docker-compose.yml up
|
||||
|
||||
version: "3.4"
|
||||
|
||||
services:
|
||||
########################################################
|
||||
# WEBAPP ###############################################
|
||||
########################################################
|
||||
webapp:
|
||||
image: ocelotsocialnetwork/develop-webapp:latest
|
||||
image: ocelotsocialnetwork/webapp:latest
|
||||
build:
|
||||
context: webapp
|
||||
context: ./webapp
|
||||
target: production
|
||||
args:
|
||||
- "BUILD_COMMIT=${TRAVIS_COMMIT}"
|
||||
ports:
|
||||
- 3000:3000
|
||||
- 3002:3002
|
||||
networks:
|
||||
- hc-network
|
||||
- external-net
|
||||
depends_on:
|
||||
- backend
|
||||
volumes:
|
||||
- ./webapp:/develop-webapp
|
||||
- webapp_node_modules:/develop-webapp/node_modules
|
||||
ports:
|
||||
- 3000:3000
|
||||
# Storybook: Todo externalize, its not working anyways
|
||||
# - 3002:3002
|
||||
environment:
|
||||
- HOST=0.0.0.0
|
||||
# Envs used in Dockerfile
|
||||
# - DOCKER_WORKDIR="/app"
|
||||
# - PORT="3000"
|
||||
- BUILD_DATE
|
||||
- BUILD_VERSION
|
||||
- BUILD_COMMIT
|
||||
- NODE_ENV="development"
|
||||
# Application only envs
|
||||
- HOST=0.0.0.0 # This is nuxt specific, alternative value is HOST=webapp
|
||||
- GRAPHQL_URI=http://backend:4000
|
||||
- MAPBOX_TOKEN="pk.eyJ1IjoiYnVzZmFrdG9yIiwiYSI6ImNraDNiM3JxcDBhaWQydG1uczhpZWtpOW4ifQ.7TNRTO-o9aK1Y6MyW_Nd4g"
|
||||
env_file:
|
||||
- ./webapp/.env
|
||||
|
||||
########################################################
|
||||
# BACKEND ##############################################
|
||||
########################################################
|
||||
backend:
|
||||
image: ocelotsocialnetwork/develop-backend:latest
|
||||
image: ocelotsocialnetwork/backend:latest
|
||||
build:
|
||||
context: backend
|
||||
context: ./backend
|
||||
target: production
|
||||
args:
|
||||
- "BUILD_COMMIT=${TRAVIS_COMMIT}"
|
||||
networks:
|
||||
- hc-network
|
||||
- external-net
|
||||
- internal-net
|
||||
depends_on:
|
||||
- neo4j
|
||||
ports:
|
||||
- 4000:4000
|
||||
volumes:
|
||||
- ./backend:/develop-backend
|
||||
- backend_node_modules:/develop-backend/node_modules
|
||||
- uploads:/develop-backend/public/uploads
|
||||
- backend_uploads:/app/public/uploads
|
||||
environment:
|
||||
# Envs used in Dockerfile
|
||||
# - DOCKER_WORKDIR="/app"
|
||||
# - PORT="4000"
|
||||
- BUILD_DATE
|
||||
- BUILD_VERSION
|
||||
- BUILD_COMMIT
|
||||
- NODE_ENV="development"
|
||||
# Application only envs
|
||||
- DEBUG=false
|
||||
- NEO4J_URI=bolt://neo4j:7687
|
||||
- GRAPHQL_URI=http://backend:4000
|
||||
- CLIENT_URI=http://localhost:3000
|
||||
- JWT_SECRET=b/&&7b78BF&fv/Vd
|
||||
- MAPBOX_TOKEN=pk.eyJ1IjoiYnVzZmFrdG9yIiwiYSI6ImNraDNiM3JxcDBhaWQydG1uczhpZWtpOW4ifQ.7TNRTO-o9aK1Y6MyW_Nd4g
|
||||
- PRIVATE_KEY_PASSPHRASE=a7dsf78sadg87ad87sfagsadg78
|
||||
- "DEBUG=${DEBUG}"
|
||||
- EMAIL_DEFAULT_SENDER=devops@ocelot.social
|
||||
- CLIENT_URI=http://webapp:3000
|
||||
env_file:
|
||||
- ./backend/.env
|
||||
|
||||
########################################################
|
||||
# NEO4J ################################################
|
||||
########################################################
|
||||
neo4j:
|
||||
image: ocelotsocialnetwork/develop-neo4j:latest
|
||||
image: ocelotsocialnetwork/neo4j:latest
|
||||
build:
|
||||
context: neo4j
|
||||
args:
|
||||
- "BUILD_COMMIT=${TRAVIS_COMMIT}"
|
||||
context: ./neo4j
|
||||
# community edition 👆🏼, because we have no enterprise licence 👇🏼 at the moment
|
||||
target: community
|
||||
networks:
|
||||
- hc-network
|
||||
environment:
|
||||
- NEO4J_AUTH=none
|
||||
- NEO4J_dbms_security_procedures_unrestricted=algo.*,apoc.*
|
||||
# decomment following line for Neo4j Enterprice version instead of Community version
|
||||
# - NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
|
||||
- internal-net
|
||||
ports:
|
||||
- 7687:7687
|
||||
- 7474:7474
|
||||
volumes:
|
||||
- neo4j_data:/data
|
||||
environment:
|
||||
# TODO: This sounds scary for a production environment
|
||||
- NEO4J_AUTH=none
|
||||
- NEO4J_dbms_security_procedures_unrestricted=algo.*,apoc.*
|
||||
# Uncomment following line for Neo4j Enterprise version instead of Community version
|
||||
# TODO: clarify if that is the only thing needed to unlock the Enterprise version
|
||||
# - NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
|
||||
# TODO: Remove the playground from production
|
||||
|
||||
########################################################
|
||||
# MAINTENANCE ##########################################
|
||||
########################################################
|
||||
maintenance:
|
||||
image: ocelotsocialnetwork/maintenance:latest
|
||||
build:
|
||||
# TODO: Separate from webapp, this must be independent
|
||||
context: ./webapp
|
||||
dockerfile: Dockerfile.maintenance
|
||||
networks:
|
||||
- external-net
|
||||
ports:
|
||||
- 5000:80
|
||||
|
||||
networks:
|
||||
hc-network:
|
||||
external-net:
|
||||
internal-net:
|
||||
internal: true
|
||||
|
||||
volumes:
|
||||
webapp_node_modules:
|
||||
backend_node_modules:
|
||||
backend_uploads:
|
||||
neo4j_data:
|
||||
uploads:
|
||||
@ -1,82 +0,0 @@
|
||||
# Installation
|
||||
|
||||
The repository can be found on GitHub. [https://github.com/Ocelot-Social-Community/Ocelot-Social](https://github.com/Ocelot-Social-Community/Ocelot-Social)
|
||||
|
||||
We give write permissions to every developer who asks for it. Just text us on
|
||||
[Discord](https://discord.gg/6ub73U3).
|
||||
|
||||
## Clone the Repository
|
||||
|
||||
|
||||
Clone the repository, this will create a new folder called `Human-Connection`:
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="HTTPS" %}
|
||||
```bash
|
||||
$ git clone https://github.com/Ocelot-Social-Community/Ocelot-Social.git
|
||||
```
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="SSH" %}
|
||||
```bash
|
||||
$ git clone git@github.com:Human-Connection/Human-Connection.git
|
||||
```
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
Change into the new folder.
|
||||
|
||||
```bash
|
||||
$ cd Human-Connection
|
||||
```
|
||||
|
||||
## Directory Layout
|
||||
|
||||
There are four important directories:
|
||||
* [Backend](./backend) runs on the server and is a middleware between database and frontend
|
||||
* [Frontend](./webapp) is a server-side-rendered and client-side-rendered web frontend
|
||||
* [Deployment](./deployment) configuration for kubernetes
|
||||
* [Cypress](./cypress) contains end-to-end tests and executable feature specifications
|
||||
|
||||
In order to setup the application and start to develop features you have to
|
||||
setup **frontend** and **backend**.
|
||||
|
||||
There are two approaches:
|
||||
|
||||
1. Local installation, which means you have to take care of dependencies yourself
|
||||
2. **Or** Install everything through docker which takes care of dependencies for you
|
||||
|
||||
## Docker Installation
|
||||
|
||||
Docker is a software development container tool that combines software and its dependencies into one standardized unit that contains everything needed to run it. This helps us to avoid problems with dependencies and makes installation easier.
|
||||
|
||||
### General Installation of Docker
|
||||
|
||||
There are [sevaral ways to install Docker CE](https://docs.docker.com/install/) on your computer or server.
|
||||
|
||||
{% tabs %}
|
||||
{% tab title="Docker Desktop macOS" %}
|
||||
Follow these instructions to [install Docker Desktop on macOS](https://docs.docker.com/docker-for-mac/install/).
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Docker Desktop Windows" %}
|
||||
Follow these instructions to [install Docker Desktop on Windows](https://docs.docker.com/docker-for-windows/install/).
|
||||
{% endtab %}
|
||||
|
||||
{% tab title="Docker CE" %}
|
||||
Follow these instructions to [install Docker CE](https://docs.docker.com/install/).
|
||||
|
||||
This is a great option for Linux users.
|
||||
{% endtab %}
|
||||
{% endtabs %}
|
||||
|
||||
Check the correct Docker installation by checking the version before proceeding. E.g. we have the following versions:
|
||||
|
||||
```bash
|
||||
$ docker --version
|
||||
Docker version 18.09.2
|
||||
$ docker-compose --version
|
||||
docker-compose version 1.23.2
|
||||
```
|
||||
|
||||
|
||||
@ -1,10 +1,43 @@
|
||||
FROM neo4j:3.5.14
|
||||
LABEL Description="Neo4J database of the Social Network ocelot.social with preinstalled database constraints and indices" Vendor="ocelot.social Community" Version="0.0.1" Maintainer="ocelot.social Community (devops@ocelot.social)"
|
||||
# community edition 👆🏼, because we have no enterprise licence 👇🏼 at the moment
|
||||
# FROM neo4j:3.5.14-enterprise
|
||||
##################################################################################
|
||||
# COMMUNITY ######################################################################
|
||||
##################################################################################
|
||||
FROM neo4j:3.5.14 as community
|
||||
|
||||
ARG BUILD_COMMIT
|
||||
ENV BUILD_COMMIT=$BUILD_COMMIT
|
||||
# ENVs (available in production aswell, can be overwritten by commandline or env file)
|
||||
## 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 $(yarn run version) here so we default to 0.0.0
|
||||
## TODO: Missing Build number - do that once we have a CI which actually generates it
|
||||
ENV BUILD_VERSION="0.0.0"
|
||||
## We cannot do `$(git rev-parse --short HEAD)` here so we default to 0000000
|
||||
ENV BUILD_COMMIT="0000000"
|
||||
|
||||
# Labels
|
||||
LABEL org.label-schema.build-date="${BUILD_DATE}"
|
||||
LABEL org.label-schema.name="ocelot.social:backend"
|
||||
LABEL org.label-schema.description="Neo4J database of the Social Network Software ocelot.social with preinstalled database constraints and indices"
|
||||
LABEL org.label-schema.usage="https://github.com/Ocelot-Social-Community/Ocelot-Social/blob/master/README.md"
|
||||
LABEL org.label-schema.url="https://ocelot.social"
|
||||
LABEL org.label-schema.vcs-url="https://github.com/Ocelot-Social-Community/Ocelot-Social/tree/master/backend"
|
||||
LABEL org.label-schema.vcs-ref="${BUILD_COMMIT}"
|
||||
LABEL org.label-schema.vendor="ocelot.social Community"
|
||||
LABEL org.label-schema.version="${BUILD_VERSION}"
|
||||
LABEL org.label-schema.schema-version="1.0"
|
||||
LABEL maintainer="devops@ocelot.social"
|
||||
|
||||
# Install Additional Software
|
||||
## install: wget, htop (TODO: why do we need htop?)
|
||||
RUN apt-get update && apt-get -y install wget htop
|
||||
## install: apoc plugin for neo4j
|
||||
RUN wget https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.5.0.4/apoc-3.5.0.4-all.jar -P plugins/
|
||||
|
||||
##################################################################################
|
||||
# ENTERPRISE #####################################################################
|
||||
##################################################################################
|
||||
FROM neo4j:3.5.14-enterprise as enterprise
|
||||
|
||||
# Install Additional Software
|
||||
## install: wget, htop (TODO: why do we need htop?)
|
||||
RUN apt-get update && apt-get -y install wget htop
|
||||
## install: apoc plugin for neo4j
|
||||
RUN wget https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.5.0.4/apoc-3.5.0.4-all.jar -P plugins/
|
||||
@ -2,5 +2,5 @@
|
||||
sed -i "s/<COMMIT>/${TRAVIS_COMMIT}/g" $TRAVIS_BUILD_DIR/scripts/patches/patch-deployment.yaml
|
||||
sed -i "s/<COMMIT>/${TRAVIS_COMMIT}/g" $TRAVIS_BUILD_DIR/scripts/patches/patch-configmap.yaml
|
||||
kubectl -n ocelot-social patch configmap develop-configmap -p "$(cat $TRAVIS_BUILD_DIR/scripts/patches/patch-configmap.yaml)"
|
||||
kubectl -n ocelot-social patch deployment develop-backend -p "$(cat $TRAVIS_BUILD_DIR/scripts/patches/patch-deployment.yaml)"
|
||||
kubectl -n ocelot-social patch deployment develop-webapp -p "$(cat $TRAVIS_BUILD_DIR/scripts/patches/patch-deployment.yaml)"
|
||||
kubectl -n ocelot-social patch deployment backend -p "$(cat $TRAVIS_BUILD_DIR/scripts/patches/patch-deployment.yaml)"
|
||||
kubectl -n ocelot-social patch deployment webapp -p "$(cat $TRAVIS_BUILD_DIR/scripts/patches/patch-deployment.yaml)"
|
||||
|
||||
@ -4,14 +4,14 @@ ROOT_DIR=$(dirname "$0")/..
|
||||
|
||||
VERSION=$(jq -r '.version' $ROOT_DIR/package.json)
|
||||
IFS='.' read -r major minor patch <<< $VERSION
|
||||
apps=(develop-webapp develop-backend develop-neo4j develop-maintenance)
|
||||
apps=(webapp backend neo4j maintenance)
|
||||
tags=($major $major.$minor $major.$minor.$patch)
|
||||
|
||||
# These three docker images have already been built by now:
|
||||
# docker build --build-arg BUILD_COMMIT=$BUILD_COMMIT --target production -t ocelotsocialnetwork/develop-backend:latest $ROOT_DIR/backend
|
||||
# docker build --build-arg BUILD_COMMIT=$BUILD_COMMIT --target production -t ocelotsocialnetwork/develop-webapp:latest $ROOT_DIR/webapp
|
||||
# docker build --build-arg BUILD_COMMIT=$BUILD_COMMIT -t ocelotsocialnetwork/develop-neo4j:latest $ROOT_DIR/neo4j
|
||||
docker build -t ocelotsocialnetwork/develop-maintenance:latest $ROOT_DIR/webapp/ -f $ROOT_DIR/webapp/Dockerfile.maintenance
|
||||
# docker build --build-arg BUILD_COMMIT=$BUILD_COMMIT --target production -t ocelotsocialnetwork/backend:latest $ROOT_DIR/backend
|
||||
# docker build --build-arg BUILD_COMMIT=$BUILD_COMMIT --target production -t ocelotsocialnetwork/webapp:latest $ROOT_DIR/webapp
|
||||
# docker build --build-arg BUILD_COMMIT=$BUILD_COMMIT -t ocelotsocialnetwork/neo4j:latest $ROOT_DIR/neo4j
|
||||
docker build -t ocelotsocialnetwork/maintenance:latest $ROOT_DIR/webapp/ -f $ROOT_DIR/webapp/Dockerfile.maintenance
|
||||
|
||||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||
|
||||
|
||||
@ -1,32 +1,89 @@
|
||||
##################################################################################
|
||||
# BASE ###########################################################################
|
||||
##################################################################################
|
||||
FROM node:12.19.0-alpine3.10 as base
|
||||
LABEL Description="Web Frontend of the Social Network ocelot.social" Vendor="ocelot.social Community" Version="0.0.1" Maintainer="ocelot.social Community (devops@ocelot.social)"
|
||||
|
||||
EXPOSE 3000
|
||||
CMD ["yarn", "run", "start"]
|
||||
# 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 $(yarn run version) here so we default to 0.0.0
|
||||
## TODO: Missing Build number - do that once we have a CI which actually generates it
|
||||
ENV BUILD_VERSION="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="3000"
|
||||
|
||||
# Expose the app port
|
||||
ARG BUILD_COMMIT
|
||||
ENV BUILD_COMMIT=$BUILD_COMMIT
|
||||
ARG WORKDIR=/develop-webapp
|
||||
RUN mkdir -p $WORKDIR
|
||||
WORKDIR $WORKDIR
|
||||
# Labels
|
||||
LABEL org.label-schema.build-date="${BUILD_DATE}"
|
||||
LABEL org.label-schema.name="ocelot.social:backend"
|
||||
LABEL org.label-schema.description="Web Frontend of the Social Network Software ocelot.social"
|
||||
LABEL org.label-schema.usage="https://github.com/Ocelot-Social-Community/Ocelot-Social/blob/master/README.md"
|
||||
LABEL org.label-schema.url="https://ocelot.social"
|
||||
LABEL org.label-schema.vcs-url="https://github.com/Ocelot-Social-Community/Ocelot-Social/tree/master/backend"
|
||||
LABEL org.label-schema.vcs-ref="${BUILD_COMMIT}"
|
||||
LABEL org.label-schema.vendor="ocelot.social Community"
|
||||
LABEL org.label-schema.version="${BUILD_VERSION}"
|
||||
LABEL org.label-schema.schema-version="1.0"
|
||||
LABEL maintainer="devops@ocelot.social"
|
||||
|
||||
# See: https://github.com/nodejs/docker-node/pull/367#issuecomment-430807898
|
||||
# Install Additional Software
|
||||
## install: git
|
||||
RUN apk --no-cache add git
|
||||
|
||||
COPY package.json yarn.lock ./
|
||||
COPY .env.template .env
|
||||
# Settings
|
||||
## Expose Container Port
|
||||
EXPOSE ${PORT}
|
||||
|
||||
## Workdir
|
||||
RUN mkdir -p ${DOCKER_WORKDIR}
|
||||
WORKDIR ${DOCKER_WORKDIR}
|
||||
|
||||
FROM base as build-and-test
|
||||
RUN yarn install --production=false --frozen-lockfile --non-interactive
|
||||
##################################################################################
|
||||
# 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 . .
|
||||
RUN NODE_ENV=production yarn run build
|
||||
# yarn install
|
||||
RUN yarn install --production=false --frozen-lockfile --non-interactive
|
||||
# yarn build
|
||||
RUN yarn run build
|
||||
|
||||
##################################################################################
|
||||
# PRODUCTION (Does contain only "binary"- and static-files to reduce image size) #
|
||||
##################################################################################
|
||||
FROM base as production
|
||||
RUN yarn install --production=true --frozen-lockfile --non-interactive --no-cache
|
||||
COPY --from=build-and-test ./develop-webapp/.nuxt ./.nuxt
|
||||
COPY --from=build-and-test ./develop-webapp/constants ./constants
|
||||
COPY --from=build-and-test ./develop-webapp/static ./static
|
||||
COPY nuxt.config.js .
|
||||
COPY locales locales
|
||||
|
||||
# Copy "binary"-files from build image
|
||||
COPY --from=build ${DOCKER_WORKDIR}/.nuxt ./.nuxt
|
||||
COPY --from=build ${DOCKER_WORKDIR}/node_modules ./node_modules
|
||||
COPY --from=build ${DOCKER_WORKDIR}/nuxt.config.js ./nuxt.config.js
|
||||
# Copy static files
|
||||
# TODO - this should be one Folder containign all stuff needed to be copied
|
||||
COPY --from=build ${DOCKER_WORKDIR}/constants ./constants
|
||||
COPY --from=build ${DOCKER_WORKDIR}/static ./static
|
||||
COPY --from=build ${DOCKER_WORKDIR}/locales ./locales
|
||||
# Copy package.json for script definitions (lock file should not be needed)
|
||||
COPY --from=build ${DOCKER_WORKDIR}/package.json ./package.json
|
||||
|
||||
# Run command
|
||||
CMD /bin/sh -c "yarn run start"
|
||||
@ -36,7 +36,7 @@ $ docker-compose up
|
||||
````
|
||||
|
||||
And the maintenance mode page or service will be started as well in an own container.
|
||||
In the browser you can reach it under `http://localhost:3503/`.
|
||||
In the browser you can reach it under `http://localhost:5000/`.
|
||||
|
||||
{% endtab %}
|
||||
{% tab title="On The Server" %}
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
"lint": "eslint --ext .js,.vue .",
|
||||
"locales": "../scripts/translations/missing-keys.sh && ../scripts/translations/sort.sh",
|
||||
"precommit": "yarn lint",
|
||||
"test": "jest",
|
||||
"test": "cross-env NODE_ENV=test jest",
|
||||
"test:unit:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --no-cache --runInBand"
|
||||
},
|
||||
"jest": {
|
||||
@ -33,7 +33,7 @@
|
||||
],
|
||||
"transform": {
|
||||
".*\\.(vue)$": "vue-jest",
|
||||
"^.+\\.js$": "<rootDir>/node_modules/babel-jest"
|
||||
"^.+\\.js$": "babel-jest"
|
||||
},
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user