Commit 12c63108 authored by Zac Wood's avatar Zac Wood
Browse files

Added Docker and CI for web. Added init.sh file to start developing

with one command
parent e46e5b81
Pipeline #2650 passed with stage
in 2 minutes and 25 seconds
stages: stages:
- test_api - test
api: test_api:
image: ruby:2.5 image: ruby:2.5
stage: test_api stage: test
script: script:
- cd schedules_api - cd schedules_api
- bundle install - bundle install
- rails db:migrate - rails db:migrate
- rails test - rails test
test_web:
image: node:9
stage: test
script:
- cd schedules_web
- yarn
- yarn build
\ No newline at end of file
...@@ -7,4 +7,12 @@ services: ...@@ -7,4 +7,12 @@ services:
- "3000:3000" - "3000:3000"
command: ./start.sh command: ./start.sh
volumes: volumes:
- .:/api - ./schedules_api:/api
web:
image: schedules_web
ports:
- "8080:8080"
command: yarn start
volumes:
- ./schedules_web:/web
#! /bin/bash
cd schedules_api/
docker build . -t 'schedules_api'
cd ../schedules_web
docker build . -t 'schedules_web'
cd ..
docker-compose up -d
docker-compose exec api rails db:seed
...@@ -4,4 +4,7 @@ RUN mkdir /api ...@@ -4,4 +4,7 @@ RUN mkdir /api
WORKDIR /api WORKDIR /api
ADD . /api ADD . /api
EXPOSE 3000
RUN bundle install RUN bundle install
RUN rails db:migrate
...@@ -7,8 +7,8 @@ export SECRET_KEY_BASE=$(rails secret) ...@@ -7,8 +7,8 @@ export SECRET_KEY_BASE=$(rails secret)
#cp db/development.sqlite3 db/production.sqlite3 #cp db/development.sqlite3 db/production.sqlite3
# load data from patriot web into database # load data from patriot web into database
# rails db:migrate rails db:migrate
# rails db:seed rails db:seed
# start the server # start the server
rails s rails s
FROM node:9
RUN mkdir /web
WORKDIR /web
ADD . /web
EXPOSE 8080
RUN yarn
\ No newline at end of file
const path = require('path'); const path = require("path");
const webpack = require('webpack'); const webpack = require("webpack");
const CleanWebpackPlugin = require("clean-webpack-plugin"); const CleanWebpackPlugin = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin"); const HtmlWebpackPlugin = require("html-webpack-plugin");
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({ const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: "./index.html", template: "./index.html",
filename: "index.html", filename: "index.html",
inject: "body" inject: "body",
}); });
module.exports = { module.exports = {
mode: "development", mode: "development",
devtool: 'source-map', devtool: "source-map",
entry: './src/index.tsx', entry: "./src/index.tsx",
output: { output: {
filename: '[name].[hash].js', filename: "[name].[hash].js",
path: path.resolve(__dirname, 'dist'), path: path.resolve(__dirname, "dist"),
}, },
resolve: { resolve: {
extensions: ['.js', '.json', '.ts', '.tsx'], extensions: [".js", ".json", ".ts", ".tsx"],
}, },
module: { module: {
rules: [{ rules: [
{
test: /\.tsx?$/, test: /\.tsx?$/,
loader: 'awesome-typescript-loader', loader: "awesome-typescript-loader",
exclude: /node_modules/, exclude: /node_modules/,
}, },
{ {
enforce: 'pre', enforce: "pre",
test: /\.js$/, test: /\.js$/,
loader: 'source-map-loader' loader: "source-map-loader",
}, },
{ {
test: /\.css$/, test: /\.css$/,
use: [{ use: [
loader: "style-loader" {
loader: "style-loader",
}, },
{ {
loader: "css-loader" loader: "css-loader",
} },
] ],
}, },
{ {
test: /\.woff(\?.+)?$/, test: /\.woff(\?.+)?$/,
use: 'url-loader?limit=10000&mimetype=application/font-woff' use: "url-loader?limit=10000&mimetype=application/font-woff",
}, },
{ {
test: /\.woff2(\?.+)?$/, test: /\.woff2(\?.+)?$/,
use: 'url-loader?limit=10000&mimetype=application/font-woff' use: "url-loader?limit=10000&mimetype=application/font-woff",
}, },
{ {
test: /\.ttf(\?.+)?$/, test: /\.ttf(\?.+)?$/,
use: 'file-loader' use: "file-loader",
}, },
{ {
test: /\.eot(\?.+)?$/, test: /\.eot(\?.+)?$/,
use: 'file-loader' use: "file-loader",
}, },
{ {
test: /\.svg(\?.+)?$/, test: /\.svg(\?.+)?$/,
use: 'file-loader' use: "file-loader",
}, },
{ {
test: /\.(js)$/, test: /\.(js)$/,
exclude: /(node_modules)/, exclude: /(node_modules)/,
loader: "babel-loader" loader: "babel-loader",
}, },
], ],
}, },
plugins: [ plugins: [new webpack.HotModuleReplacementPlugin(), new CleanWebpackPlugin(["dist"]), HtmlWebpackPluginConfig],
new webpack.HotModuleReplacementPlugin(),
new CleanWebpackPlugin(["dist"]),
HtmlWebpackPluginConfig
],
devServer: { devServer: {
contentBase: path.resolve(__dirname, "dist"), contentBase: path.resolve(__dirname, "dist"),
compress: true, compress: true,
host: "0.0.0.0",
port: 8080, port: 8080,
hot: true, hot: true,
publicPath: "/", publicPath: "/",
historyApiFallback: true historyApiFallback: true,
} },
}; };
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment