Skip to content

Commit

Permalink
massive housecleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
hongee committed May 21, 2018
1 parent c76cee7 commit fded969
Show file tree
Hide file tree
Showing 90 changed files with 63 additions and 39 deletions.
13 changes: 11 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,14 @@ Dockerfile
.editorconfig
.gitlab-ci.yml

assets/bundles/
static/
kerckhoff/assets/bundles/
static/

stats.json
webpack-stats.json
npm-debug.log

*/**/__pycache__/
v8-compile-cache*

.mypy_cache
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ ENV/
node_modules/
webpack-stats.json

assets/bundles/
.vscode
kerckhoff/assets/bundles/**/*

# General
*.DS_Store
Expand All @@ -112,6 +111,6 @@ assets/bundles/

stats.json

static/
kerckhoff/static/**/*

v8-compile-cache*/**/*
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"python.pythonPath": "/Users/hongee/Envs/kerckhoff-C7DUdSyH/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": false,
"python.linting.mypyEnabled": false
}
20 changes: 14 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
# Stage 0 - Node build
FROM node:8
WORKDIR /kerckhoff
ENV DEBUG False
ADD package.json package-lock.json /kerckhoff/
RUN npm i
COPY ./webpack.config.js ./jsconfig.json ./
COPY ./kerckhoff/assets ./kerckhoff/assets
RUN npm run build

# Stage 1 - Python dependencies
FROM python:3-slim
ENV PYTHONUNBUFFERED 1
RUN mkdir /kerckhoff

RUN apt-get update && apt-get install -y curl \
git \
build-essential
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash
RUN apt-get install -y nodejs

WORKDIR /kerckhoff

ADD requirements.txt /kerckhoff/
RUN pip install -r requirements.txt

ADD package.json package-lock.json /kerckhoff/
RUN npm install
# Get the webpack built assets from the previous stage
COPY --from=0 /kerckhoff /kerckhoff

ADD . /kerckhoff/
EXPOSE 5000

ENTRYPOINT [ "./prod-entrypoint.sh" ]
CMD "./prod.sh"
20 changes: 0 additions & 20 deletions assets/js/util.js

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
web:
build: .
image: kerckhoff
command: python3 manage.py runserver 0.0.0.0:5000
command: python3 kerckhoff/manage.py runserver 0.0.0.0:5000
entrypoint: ./dev-entrypoint.sh
ports:
- "5000:5000"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions kerckhoff/assets/js/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import axios from "axios";
import Cookies from "js-cookie";

axios.defaults.xsrfHeaderName = "X-CSRFToken";
axios.defaults.xsrfCookieName = "csrftoken";

const utils = {
getCSRFToken: () => {
return Cookies.get("csrftoken");
},

asFormData: obj => {
Object.keys(obj).reduce((formData, key) => {
formData.append(key, obj[key]);
return formData;
}, new FormData());
}
};

export { utils, axios };
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion kerckhoff/settings.py → kerckhoff/kerckhoff/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
'DEFAULT': {
'CACHE': not DEBUG,
'BUNDLE_DIR_NAME': 'bundles/',
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
'STATS_FILE': os.path.join(os.path.dirname(BASE_DIR), 'webpack-stats.json'),
}
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions prod-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/sh
set -e
# Build Webpack
echo "Building webpack..."
npm run build

cd kerckhoff

# Collect static files
echo "Collect static files"
Expand All @@ -12,4 +11,6 @@ python manage.py collectstatic --noinput
echo "Apply database migrations"
python manage.py migrate

cd ..

exec "$@"
1 change: 1 addition & 0 deletions prod.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/sh
cd kerckhoff
gunicorn -b 0.0.0.0:5000 -w 4 -k gthread --threads 2 kerckhoff.wsgi --log-file -
6 changes: 3 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ module.exports = {
mode: process.env.DEBUG == "True" ? "development" : "production",

entry: {
main: "./assets/js/main",
management: "./assets/js/management"
main: "./kerckhoff/assets/js/main",
management: "./kerckhoff/assets/js/management"
},

output: {
path: path.resolve("./assets/bundles/"),
path: path.resolve("./kerckhoff/assets/bundles/"),
filename: "[name]-[hash].js"
},

Expand Down

0 comments on commit fded969

Please sign in to comment.