Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit 9c2a7cb

Browse files
authored
Add Docker files to client and server (#41)
* Add Dockerfile to client side * Cleanup * Docker for django app (server) works
1 parent bd4cc42 commit 9c2a7cb

File tree

6 files changed

+56
-8
lines changed

6 files changed

+56
-8
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# An opinionated Angular - Django cluster
1+
# An opinionated Angular - Django RESTful cluster
22

33
[![license][license-image]][license-url] [![Build Status][travis-image]][travis-url] [![codecov][codecov-image]][codecov-url] [![Dependency Status][dependencyci-image]][dependencyci-url] [![Donate][donate-image]][donate-url]
44

@@ -15,16 +15,19 @@ The repo is a production ready app, that uses `nginx` to serve static files (the
1515

1616
Automatic installation of the project with docker, for development.
1717

18-
1. Run `$ docker-compose up` to build the docker images and run them.
19-
3. Open the browser at [http://localhost:8000](http://localhost:8000) to see your Django (server) app.
18+
1. In `client` directory run `docker build -t client .` to build the Docker image.
19+
2. Run ```docker run -dit -v `pwd`:/usr/src -p 4200:4200 --name=client-con client``` to run a container from that image.
2020
3. Open the browser at [http://localhost:4200](http://localhost:4200) to see your Angular (client) app.
21+
4. In `server` directory run `docker build -t server .` to build the Docker image.
22+
5. Run ```docker run -dit -v `pwd`:/usr/src -p 8000:8000 --name=server-con server``` to run a container from that image.
23+
6. Open the browser at [http://localhost:8000](http://localhost:8000) to see your Django (server) app.
2124

2225
If you want to install the project manually, go to the `/client` or `/server` directories and read the `README` file.
2326

2427
## Our Stack
2528

26-
* [Angular 2.3](https://angular.io/)
27-
* [Django 1.10.5](https://www.djangoproject.com/)
29+
* [Angular](https://angular.io/)
30+
* [Django](https://www.djangoproject.com/)
2831
* [PostgreSQL](http://www.postgresql.org/)
2932
* [Docker](https://www.docker.com/)
3033

client/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM node:latest
2+
MAINTAINER Nir Galon <[email protected]>
3+
4+
RUN useradd --user-group --create-home --shell /bin/false app
5+
6+
ENV APP_NAME "client"
7+
ENV APP_USER "app"
8+
ENV HOME /home/$APP_USER
9+
ENV APP_DIR $HOME/$APP_NAME
10+
11+
RUN npm install --global --silent angular-cli
12+
13+
WORKDIR $APP_DIR
14+
COPY package.json $APP_DIR/package.json
15+
RUN npm install --silent && npm cache clean
16+
COPY . $APP_DIR
17+
RUN chown -R $APP_USER:$APP_USER $HOME/*
18+
19+
USER $APP_USER
20+
WORKDIR $APP_DIR
21+
22+
EXPOSE 4200
23+
24+
CMD ["npm", "start"]

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"angular-cli": {},
66
"scripts": {
77
"ng": "ng",
8-
"start": "ng serve --proxy-config proxy.conf.json",
8+
"start": "ng serve --host=0.0.0.0 --proxy-config proxy.conf.json",
99
"lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check",
1010
"test": "ng test --single-run --code-coverage",
1111
"pree2e": "webdriver-manager update --standalone false --gecko false",

server/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM python:3-onbuild
2+
MAINTAINER Nir Galon <[email protected]>
3+
4+
RUN useradd --user-group --create-home --shell /bin/false app
5+
6+
ENV APP_NAME "server"
7+
ENV APP_USER "app"
8+
ENV HOME /home/$APP_USER
9+
ENV APP_DIR $HOME/$APP_NAME
10+
11+
WORKDIR $APP_DIR
12+
COPY requirements.txt $APP_DIR/requirements.txt
13+
14+
COPY . $APP_DIR
15+
RUN chown -R $APP_USER:$APP_USER $HOME/*
16+
17+
USER $APP_USER
18+
WORKDIR $APP_DIR
19+
20+
EXPOSE 8000
21+
CMD ["gunicorn", "config.wsgi", "-b", "0.0.0.0:8000"]

server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## server
1+
## Server
22

33
The server (backend) side of the project written [Python](https://www.python.org/) using [Django 1.10.5](https://www.djangoproject.com/), [Django REST framework](http://www.django-rest-framework.org/).
44

server/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Install with: `pip install -r requirements.txt`
22

3-
Django==1.10.5
3+
Django==1.10.6
44
psycopg2==2.6.2
55
django-extensions==1.7.7
66
gunicorn==19.6.0

0 commit comments

Comments
 (0)