Skip to content
Snippets Groups Projects
Commit 27ba25eb authored by Léo Banno-Cloutier's avatar Léo Banno-Cloutier
Browse files

Dockerfile: created dev and prod environment

This adds a dev environment, which enables hot reloading on
jams-react-client. Also, maven can now properly cache its dependencies,
making recompilation faster

Change-Id: If9561ccadc7c7c116446fd47f4b041cb371b9760
parent f96bf728
No related branches found
No related tags found
No related merge requests found
.git
.gitignore
Dockerfile
.dockerignore
**/node_modules
......
......@@ -17,16 +17,36 @@ COPY jams-common/pom.xml jams-common/pom.xml
COPY jams-launcher/pom.xml jams-launcher/pom.xml
COPY ldap-connector/pom.xml ldap-connector/pom.xml
COPY jams-server/pom.xml jams-server/pom.xml
# RUN mvn verify --fail-never
# RUN mvn dependency:resolve --fail-never
RUN mvn dependency:go-offline --fail-never
# RUN mvn dependency:go-offline --fail-never -am
RUN mvn install -pl ad-connector,authentication-module,datastore,jami-dht,jami-nameserver,jams-ca,jams-common,jams-launcher,ldap-connector,jams-server -am -DskipTests
COPY . .
# RUN mvn clean package
FROM build as dev
WORKDIR /app
RUN mkdir -p /app/jams-server/src/main/resources/webapp \
&& echo '<h1>Dev build, please connect to <a href="http://localhost:3000">localhost:3000</a> instead</h1>' \
> /app/jams-server/src/main/resources/webapp/index.html
RUN mvn package
WORKDIR /app/jams
EXPOSE 3000 8080
CMD java -jar jams-launcher.jar & npm start --prefix ../jams-react-client
FROM adoptopenjdk/openjdk11:jdk-11.0.2.9-alpine
FROM build as prod
WORKDIR /app/jams-react-client
RUN npm run build
RUN mv build ../jams-server/src/main/resources/webapp
WORKDIR /app
COPY --from=build /app/jams .
EXPOSE 8080
ENTRYPOINT ["java","-jar","jams-launcher.jar"]
RUN mvn package
ENV JAMS_VERSION=3.4
RUN python3 generate-versions.py net.jami.jams.ca.JamsCA $JAMS_VERSION libs/cryptoengine.jar
RUN python3 generate-versions.py net.jami.jams.authmodule.UserAuthenticationModule $JAMS_VERSION libs/authentication-module.jar
RUN python3 generate-versions.py net.jami.jams.server.Server $JAMS_VERSION jams-server.jar
RUN python3 generate-versions.py net.jami.jams.ad.connector.ADConnector $JAMS_VERSION libs/ad-connector.jar
RUN python3 generate-versions.py net.jami.jams.ldap.connector.LDAPConnector $JAMS_VERSION libs/ldap-connector.jar
RUN ./build-doc.sh
CMD ["cp", "-r", "jams/.", "/jams"]
#### JAMS (Jami Account Management Server)
# JAMS (Jami Account Management Server)
##### Requirements
## Requirements
- JDK 11+
- maven
##### Building from source
## Building from source
Clone the contents of this repository and run
```
cd jams-react-client
npm install
npm start
cd ..
mvn clean package
```
......@@ -32,7 +28,7 @@ from 8080, then run:
Where the `pem` and `key` files are a pem encoded certificate and key.
##### How to generate server.pem and server.key pair
## How to generate server.pem and server.key pair
In order to generate a pair of pem and key use the following command using openssl
......@@ -45,7 +41,7 @@ This can be completed by running `npm install -g apidoc`, if for some reason
that does not work, you can clone their project from : https://github.com/apidoc/apidoc
and install it from source.
To build the documentation, change enter the `jams-server` directory and simply run:
To build the documentation, enter the `jams-server` directory and simply run:
`apidoc -i src/ -o doc/`
......@@ -62,16 +58,26 @@ chmod +x .git/hooks/pre-commit
## Development Docker container
You can build the docker container using:
A development environment with react hot reloading can be created using:
```
docker build -f Dockerfile -t jams:latest .
docker build -f Dockerfile -t jams:dev --target dev .
docker run -it -p 3000:3000 -p 8080:8080 \
-v $(pwd)/jams-react-client/src:/app/jams-react-client/src \
-v $(pwd)/jams-react-client/public:/app/jams-react-client/public \
--rm jams:dev
```
To run the docker container (assuming you want to have it on port 8080 locally):
Note: It is possible that after 15 minutes, the user's token expires, the server
will answer with a "You are not authentified" and forget to put the CORS
headers, thus the browser will refuse to read the response. In this case, you
will need to restart the server.
## Generate jams with Docker
The following commands will generate the userguide and the jars needed:
```
docker run -p 8080:8080 --rm jams:latest
docker build -f Dockerfile -t jams:latest --target prod .
docker run -v $(pwd)/jams:/jams --rm jams:latest
sudo chown -R $(whoami) jams
```
## About jams-server/src/main/java/net/jami/jams/server/filters
......
import hashlib
import json
import sys
import hashlib
import os
from pathlib import Path
def read_versions(versions_file: Path) -> dict:
if not versions_file.exists():
return {}
with open(versions_file) as f:
return json.load(f)
os.chdir("..")
className = sys.argv[1]
version = sys.argv[2]
try:
filename = sys.argv[3].split("/")[1]
except:
def main() -> None:
here = Path(__file__).parent
versions_file = here / "versions.json"
class_name = sys.argv[1]
version = sys.argv[2]
filename = sys.argv[3]
try:
f = open("versions.json", "r")
map = json.loads(f.read())
except:
map = {}
map[className] = {}
map[className]['version'] = version
map[className]['filename'] = filename
md5_hash = hashlib.md5()
a_file = open("jams/" + sys.argv[3], "rb")
content = a_file.read()
md5_hash.update(content)
digest = md5_hash.hexdigest()
map[className]['md5'] = digest
f = open("versions.json", "w")
f.write(json.dumps(map,indent=4))
f.close()
versions = read_versions(versions_file)
md5_hash = hashlib.md5()
with open(here / "jams" / filename, "rb") as jar:
md5_hash.update(jar.read())
versions[class_name] = {
"version": version,
"filename": filename,
"md5": md5_hash.hexdigest(),
}
with open(versions_file, "w") as f:
json.dump(versions, f, indent=4)
if __name__ == "__main__":
main()
#!/bin/bash
set -eo pipefail
#Build the UI from the react js folder.
cd ../jams-react-client || exit
npm install
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment