Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Scalingo deploy #1

Draft
wants to merge 14 commits into
base: develop
Choose a base branch
from
7 changes: 7 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM mcr.microsoft.com/devcontainers/base:latest

RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.zsh_history" \
&& mkdir /commandhistory \
&& touch /commandhistory/.zsh_history \
&& chown -R vscode /commandhistory \
&& echo "$SNIPPET" >> "/home/vscode/.zshrc"
19 changes: 19 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"postCreateCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
"features": {
"ghcr.io/audacioustux/devcontainers/taskfile:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "v12.22.12"
}
},
"forwardPorts": [
3000,
"postgres:5432",
"redis:6379"
]
}
53 changes: 53 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: "3"

services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile

volumes:
- $PWD:/workspaces/kutt:cached
- shellhistory:/commandhistory
environment:
DB_NAME: kutt
DB_HOST: db
DB_PORT: 5432
DB_USER: user

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Runs app on the same network as the database container
networks:
- kutt_network

redis:
image: redis:6.0-alpine
volumes:
- redis_data:/data
networks:
- kutt_network
ports:
- "6379:6379"

postgres:
image: postgres:12-alpine
environment:
POSTGRES_USER: user
POSTGRES_DB: kutt
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
networks:
- kutt_network

networks:
kutt_network:

volumes:
redis_data:
postgres_data:
shellhistory:
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
flow-typed/
node_modules/
client/**/__test__/
production-server
production-server
next.config.js
4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ FROM node:12-alpine

RUN apk add --update bash

# Setting working directory.
# Setting working directory.
WORKDIR /usr/src/app

# Installing dependencies
COPY package*.json ./
RUN npm install
RUN npm ci

# Copying source files
COPY . .
Expand All @@ -21,4 +21,4 @@ RUN npm run build
EXPOSE 3000

# Running the app
CMD [ "npm", "start" ]
CMD [ "npm", "start" ]
2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
postdeploy: npm run migrate
web: node production-server/server.js
2 changes: 1 addition & 1 deletion knexfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import env from "./server/env";
module.exports = {
production: {
client: "postgresql",
connection: {
connection: env.DATABASE_URL || {
host: env.DB_HOST,
database: env.DB_NAME,
user: env.DB_USER,
Expand Down
Loading