Make website Docker ready

This commit is contained in:
2020-06-01 16:09:57 +02:00
parent be3a400512
commit 466b9ea8db
7 changed files with 123 additions and 1 deletions

25
.drone.yml Normal file
View File

@@ -0,0 +1,25 @@
kind: pipeline
type: docker
name: default
steps:
- name: Build and push frontend image
image: plugins/docker
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
dockerfile: frontend/Dockerfile
repo: docker.humenius.me/humenius/ts-onlinetime-ranks-frontend
tags: latest
- name: Build and push backend image
image: plugins/docker
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
dockerfile: backend/Dockerfile
repo: docker.humenius.me/humenius/ts-onlinetime-ranks-backend
tags: latest

12
backend/Dockerfile Normal file
View File

@@ -0,0 +1,12 @@
FROM node:alpine AS builder
WORKDIR /app
COPY ./package.json ./
RUN npm install
COPY . .
RUN npm run build
FROM node:alpine
WORKDIR /app
COPY --from=builder /app ./
CMD ["npm", "run", "start:prod"]

48
docker-compose.yml Normal file
View File

@@ -0,0 +1,48 @@
version: '3.7'
services:
frontend:
image: docker.humenius.me/humenius/ts-onlinetime-ranks-frontend:latest
networks:
- proxy
labels:
- traefik.enable=true
# HTTP + Redirect
- traefik.http.routers.aboutme.entrypoints=http
- traefik.http.routers.aboutme.rule=Host(`tsotr.humenius.me`)
- traefik.http.routers.aboutme.middlewares=aboutme-https-redirect
- traefik.http.middlewares.aboutme-https-redirect.redirectscheme.scheme=https
# HTTPS + Port + network
- traefik.http.routers.aboutme-secure.entrypoints=https
- traefik.http.routers.aboutme-secure.rule=(`tsotr.humenius.me`)
- traefik.http.routers.aboutme-secure.tls=true
- traefik.http.routers.aboutme-secure.tls.certresolver=http
- traefik.http.services.aboutme.loadbalancer.server.port=80
- traefik.docker.network=proxy
backend:
image: docker.humenius.me/humenius/ts-onlinetime-ranks-backend:latest
networks:
- proxy
labels:
- traefik.enable=true
# HTTP + Redirect
- traefik.http.routers.aboutme.entrypoints=http
- traefik.http.routers.aboutme.rule=(Host(`tsotr.humenius.me`) && Path(`/api`))
- traefik.http.routers.aboutme.middlewares=aboutme-https-redirect
- traefik.http.middlewares.aboutme-https-redirect.redirectscheme.scheme=https
# HTTPS + Port + network
- traefik.http.routers.aboutme-secure.entrypoints=https
- traefik.http.routers.aboutme-secure.rule=(Host(`tsotr.humenius.me`) && Path(`/api`))
- traefik.http.routers.aboutme-secure.tls=true
- traefik.http.routers.aboutme-secure.tls.certresolver=http
- traefik.http.services.aboutme.loadbalancer.server.port=3500
- traefik.docker.network=proxy
networks:
proxy:
external: true

15
frontend/Dockerfile Normal file
View File

@@ -0,0 +1,15 @@
FROM node:alpine as builder
WORKDIR '/app'
COPY ./package.json ./
RUN yarn
COPY . .
RUN yarn build
FROM nginx:alpine
LABEL maintainer="Kevin Reis <contact@humenius.me>"
COPY --from=builder /app/build /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/conf.d
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

10
frontend/Dockerfile.dev Normal file
View File

@@ -0,0 +1,10 @@
FROM node:alpine
WORKDIR '/app'
COPY package.json .
RUN yarn
COPY . .
CMD ["yarn", "start"]

12
frontend/nginx/nginx.conf Normal file
View File

@@ -0,0 +1,12 @@
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

View File

@@ -2,7 +2,7 @@
"name": "ts-onlinetime-ranks",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:3500",
"proxy": "http://tsotr.humenius.me/api",
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",