Skip to content

Commit c0d3ab0

Browse files
committed
Update dockerfile to build content using webpack
1 parent 15e806d commit c0d3ab0

7 files changed

+22
-22
lines changed

.dockerignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,5 +260,5 @@ cython_debug/
260260
.idea
261261
sqlite_db
262262

263-
static/assets/
263+
snowflake/static/assets/
264264

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,4 @@ dmypy.json
134134
sqlite_db
135135

136136
node_modules/
137-
static/assets/
137+
snowflake/static/assets/

Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
FROM node:latest as static
2+
3+
WORKDIR /app
4+
5+
COPY package*.json /app/
6+
RUN npm install
7+
8+
COPY .babelrc /app/
9+
COPY webpack.config.js/ /app/
10+
COPY _frontend/ /app/_frontend
11+
12+
13+
RUN mkdir -p snowflake/static/assets && npm run build
14+
115
FROM python:3
216

317
WORKDIR /app
@@ -9,5 +23,6 @@ COPY Pipfile* /app/
923
RUN pipenv install --system
1024

1125
COPY . /app
26+
COPY --from=static /app/snowflake/static/assets /app/snowflake/static/assets
1227

1328
CMD gunicorn --bind 0.0.0.0:5000 snowflake:app

docker-compose.yml

-13
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,3 @@ services:
66
- .env
77
ports:
88
- 5432:5432
9-
app:
10-
depends_on:
11-
- db
12-
build: .
13-
env_file:
14-
- .env
15-
environment:
16-
- PGHOST=db
17-
ports:
18-
- 5000:5000
19-
volumes:
20-
- .:/app
21-
command: 'python -m snowflake'

migration.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
from dataclasses import dataclass
55

6-
from db import open_connection
6+
from snowflake.db import open_connection
77

88

99
@dataclass

snowflake/app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
OneOnOneActionItemStateChange
1919
from .models import Appreciation, Comment, Like, Mention, OneOnOne, OneOnOneActionItem, User
2020

21-
app = Flask(__name__, static_folder="../static")
21+
app = Flask(__name__)
2222
app.secret_key = settings.SECRET_KEY
2323

2424
login_manager = LoginManager()

webpack.config.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ const {CleanWebpackPlugin} = require("clean-webpack-plugin");
33

44
const Manifest = require('webpack-manifest-plugin');
55

6-
const isDev = process.env.NODE_ENV !== 'production';
7-
86
module.exports = {
97
"entry": {
10-
"main": "./_frontend/index.js"
8+
"main": path.resolve(__dirname, "_frontend/index.js")
119
},
1210
"output": {
1311
"filename": "[name]-[chunkhash].js",
14-
"path": path.resolve(__dirname, "static/assets"),
12+
"path": path.resolve(__dirname, "snowflake/static/assets"),
1513
},
1614
"module": {
1715
"rules": [
@@ -45,6 +43,6 @@ module.exports = {
4543
new Manifest({writeToFileEmit: true})
4644
],
4745
devServer: {
48-
contentBase: path.resolve(__dirname, "static/assets"),
46+
contentBase: path.resolve(__dirname, "snowflake/static/assets"),
4947
},
5048
};

0 commit comments

Comments
 (0)