reformat docker setup to remove traefik dependency

This commit is contained in:
Amruth Pillai
2022-08-29 09:03:23 +02:00
parent 2c95dc2ac8
commit d73ee7b7f8
10 changed files with 110 additions and 116 deletions
+3 -3
View File
@@ -1,3 +1,6 @@
# Android App
/app
# Build Artifacts # Build Artifacts
dist dist
.next .next
@@ -22,6 +25,3 @@ node_modules
Dockerfile Dockerfile
.dockerignore .dockerignore
docker-compose.yml docker-compose.yml
# Android App
/app
+2 -2
View File
@@ -4,8 +4,8 @@ TURBO_TOKEN=
# Server + Client # Server + Client
TZ=UTC TZ=UTC
PUBLIC_URL=http://client:3000 PUBLIC_URL=http://localhost:3000
PUBLIC_SERVER_URL=http://server:3100 PUBLIC_SERVER_URL=http://localhost:3100
PUBLIC_GOOGLE_CLIENT_ID= PUBLIC_GOOGLE_CLIENT_ID=
# Server + Database # Server + Database
-13
View File
@@ -15,19 +15,6 @@ const nextConfig = {
domains: ['cdn.rxresu.me', 'www.gravatar.com'], domains: ['cdn.rxresu.me', 'www.gravatar.com'],
}, },
async rewrites() {
if (process.env.NODE_ENV === 'development') {
return [
{
source: '/api/:path*',
destination: 'http://localhost:3100/:path*',
},
];
}
return [];
},
// Hack to make Tailwind darkMode 'class' strategy with CSS Modules // Hack to make Tailwind darkMode 'class' strategy with CSS Modules
// Ref: https://github.com/tailwindlabs/tailwindcss/issues/3258#issuecomment-968368156 // Ref: https://github.com/tailwindlabs/tailwindcss/issues/3258#issuecomment-968368156
webpack: (config) => { webpack: (config) => {
+35 -37
View File
@@ -18,46 +18,44 @@ import queryClient from '@/services/react-query';
import store, { persistor } from '@/store/index'; import store, { persistor } from '@/store/index';
import WrapperRegistry from '@/wrappers/index'; import WrapperRegistry from '@/wrappers/index';
const App: React.FC<AppProps> = ({ Component, pageProps }) => { const App: React.FC<AppProps> = ({ Component, pageProps }) => (
return ( <>
<> <Head>
<Head> <title>Reactive Resume</title>
<title>Reactive Resume</title>
<meta <meta
name="description" name="description"
content="Reactive Resume is a free and open source resume builder that's built to make the mundane tasks of creating, updating and sharing your resume as easy as 1, 2, 3." content="Reactive Resume is a free and open source resume builder that's built to make the mundane tasks of creating, updating and sharing your resume as easy as 1, 2, 3."
/> />
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="initial-scale=1, width=device-width" /> <meta name="viewport" content="initial-scale=1, width=device-width" />
</Head> </Head>
<ReduxProvider store={store}> <ReduxProvider store={store}>
<LocalizationProvider dateAdapter={DayjsAdapter}> <LocalizationProvider dateAdapter={DayjsAdapter}>
<PersistGate loading={null} persistor={persistor}> <PersistGate loading={null} persistor={persistor}>
<GoogleOAuthProvider clientId={env('GOOGLE_CLIENT_ID')}> <GoogleOAuthProvider clientId={env('GOOGLE_CLIENT_ID')}>
<QueryClientProvider client={queryClient}> <QueryClientProvider client={queryClient}>
<WrapperRegistry> <WrapperRegistry>
<Loading /> <Loading />
<Component {...pageProps} /> <Component {...pageProps} />
<ModalWrapper /> <ModalWrapper />
<Toaster <Toaster
position="bottom-right" position="bottom-right"
toastOptions={{ toastOptions={{
duration: 4000, duration: 4000,
className: 'toast', className: 'toast',
}} }}
/> />
</WrapperRegistry> </WrapperRegistry>
</QueryClientProvider> </QueryClientProvider>
</GoogleOAuthProvider> </GoogleOAuthProvider>
</PersistGate> </PersistGate>
</LocalizationProvider> </LocalizationProvider>
</ReduxProvider> </ReduxProvider>
</> </>
); );
};
export default appWithTranslation(App); export default appWithTranslation(App);
+5 -3
View File
@@ -1,3 +1,4 @@
import env from '@beam-australia/react-env';
import _axios from 'axios'; import _axios from 'axios';
import Router from 'next/router'; import Router from 'next/router';
@@ -6,13 +7,14 @@ import { logout } from '@/store/auth/authSlice';
import store from '../store'; import store from '../store';
export type ServerError = { export type ServerError = {
statusCode: number; path: string;
message: string; message: string;
timestamp: string; timestamp: string;
path: string; statusCode: number;
}; };
const axios = _axios.create({ baseURL: '/api' }); const baseURL = env('SERVER_URL') || '/api';
const axios = _axios.create({ baseURL });
axios.interceptors.request.use((config) => { axios.interceptors.request.use((config) => {
const { accessToken } = store.getState().auth; const { accessToken } = store.getState().auth;
+2 -6
View File
@@ -1,6 +1,5 @@
import env from '@beam-australia/react-env';
import { Resume } from '@reactive-resume/schema'; import { Resume } from '@reactive-resume/schema';
import _axios, { AxiosResponse } from 'axios'; import { AxiosResponse } from 'axios';
import isBrowser from '@/utils/isBrowser'; import isBrowser from '@/utils/isBrowser';
@@ -63,12 +62,9 @@ export const fetchResumeByIdentifier = async ({
options = { secretKey: '' }, options = { secretKey: '' },
}: FetchResumeByIdentifierParams) => { }: FetchResumeByIdentifierParams) => {
if (!isBrowser) { if (!isBrowser) {
const serverUrl = env('SERVER_URL');
const secretKey = options.secretKey; const secretKey = options.secretKey;
return _axios return axios.get<Resume>(`/resume/${username}/${slug}`, { params: { secretKey } }).then((res) => res.data);
.get<Resume>(`${serverUrl}/resume/${username}/${slug}`, { params: { secretKey } })
.then((res) => res.data);
} }
return axios.get<Resume>(`/resume/${username}/${slug}`).then((res) => res.data); return axios.get<Resume>(`/resume/${username}/${slug}`).then((res) => res.data);
+54 -43
View File
@@ -1,68 +1,79 @@
version: '3.8' version: "3.8"
services: services:
postgres: postgres:
image: postgres:alpine image: postgres:alpine
container_name: postgres container_name: postgres
restart: always
ports: ports:
- 5432:5432 - 5432:5432
env_file: .env.docker
volumes: volumes:
- pgdata:/var/lib/postgresql/data - pgdata:/var/lib/postgresql/data
healthcheck: healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres" ] test: ["CMD-SHELL", "pg_isready -U postgres"]
start_period: 15s start_period: 15s
interval: 30s interval: 30s
timeout: 30s timeout: 30s
retries: 3 retries: 3
restart: always environment:
- POSTGRES_DB=postgres
traefik: - POSTGRES_USER=postgres
image: traefik:latest - POSTGRES_PASSWORD=postgres
container_name: traefik
command:
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --entrypoints.web.address=:80
ports:
- 80:80
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
server: server:
# image: amruthpillai/reactive-resume:server-latest image: amruthpillai/reactive-resume:server-latest
build: # build:
context: . # context: .
dockerfile: ./server/Dockerfile # dockerfile: ./server/Dockerfile
container_name: server container_name: server
env_file: .env.docker
depends_on:
- traefik
- postgres
labels:
- traefik.enable=true
- traefik.http.routers.server.entrypoints=web
- traefik.http.routers.server.rule=Host(`localhost`) && PathPrefix(`/api/`)
- traefik.http.routers.server.middlewares=server-stripprefix
- traefik.http.middlewares.server-stripprefix.stripprefix.prefixes=/api
- traefik.http.middlewares.server-stripprefix.stripprefix.forceslash=true
restart: always restart: always
ports:
- 3100:3100
depends_on:
- postgres
environment:
- PUBLIC_URL=http://localhost:3000
- PUBLIC_SERVER_URL=http://localhost:3100
- PUBLIC_GOOGLE_CLIENT_ID=
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- SECRET_KEY=change-me-to-something-secure
- POSTGRES_HOST=postgres
- POSTGRES_PORT=5432
- POSTGRES_SSL_CERT=
- JWT_SECRET=change-me-to-something-secure
- JWT_EXPIRY_TIME=604800
- GOOGLE_CLIENT_SECRET=
- GOOGLE_API_KEY=
- MAIL_FROM_NAME=Reactive Resume
- MAIL_FROM_EMAIL=noreply@rxresu.me
- MAIL_HOST=
- MAIL_PORT=
- MAIL_USERNAME=
- MAIL_PASSWORD=
- STORAGE_BUCKET=
- STORAGE_REGION=
- STORAGE_ENDPOINT=
- STORAGE_URL_PREFIX=
- STORAGE_ACCESS_KEY=
- STORAGE_SECRET_KEY=
client: client:
# image: amruthpillai/reactive-resume:client-latest image: amruthpillai/reactive-resume:client-latest
build: # build:
context: . # context: .
dockerfile: ./client/Dockerfile # dockerfile: ./client/Dockerfile
container_name: client container_name: client
env_file: .env.docker
depends_on:
- traefik
- server
labels:
- traefik.enable=true
- traefik.http.routers.client.rule=Host(`localhost`)
- traefik.http.routers.client.entrypoints=web
restart: always restart: always
ports:
- 3000:3000
depends_on:
- server
environment:
- PUBLIC_URL=http://localhost:3000
- PUBLIC_SERVER_URL=http://localhost:3100
- PUBLIC_GOOGLE_CLIENT_ID=
volumes: volumes:
pgdata: pgdata:
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "reactive-resume", "name": "reactive-resume",
"version": "3.6.3", "version": "3.6.4",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "env-cmd --silent turbo run dev", "dev": "env-cmd --silent turbo run dev",
+7 -7
View File
@@ -240,7 +240,7 @@ importers:
ts-loader: ^9.3.1 ts-loader: ^9.3.1
ts-node: ^10.9.1 ts-node: ^10.9.1
tsconfig-paths: ^4.1.0 tsconfig-paths: ^4.1.0
typeorm: 0.3.8 typeorm: 0.3.9
typescript: ^4.8.2 typescript: ^4.8.2
uuid: ^8.3.2 uuid: ^8.3.2
webpack: ^5.74.0 webpack: ^5.74.0
@@ -257,7 +257,7 @@ importers:
'@nestjs/schedule': 2.1.0_fvppslgepxggj3fnmtlnh4cori '@nestjs/schedule': 2.1.0_fvppslgepxggj3fnmtlnh4cori
'@nestjs/serve-static': 3.0.0_khr6mt6ojlxbw7bo55fknouh34 '@nestjs/serve-static': 3.0.0_khr6mt6ojlxbw7bo55fknouh34
'@nestjs/terminus': 9.1.1_mr622mjrz7hsw5sxbt7k6brday '@nestjs/terminus': 9.1.1_mr622mjrz7hsw5sxbt7k6brday
'@nestjs/typeorm': 9.0.1_st2lgrtczmd47ypuvaupbfaph4 '@nestjs/typeorm': 9.0.1_tq7xycdignr3g27t42km5o6vju
'@types/passport': 1.0.10 '@types/passport': 1.0.10
bcryptjs: 2.4.3 bcryptjs: 2.4.3
cache-manager: 4.1.0 cache-manager: 4.1.0
@@ -282,7 +282,7 @@ importers:
reflect-metadata: 0.1.13 reflect-metadata: 0.1.13
rimraf: 3.0.2 rimraf: 3.0.2
rxjs: 7.5.6 rxjs: 7.5.6
typeorm: 0.3.8_pg@8.8.0+ts-node@10.9.1 typeorm: 0.3.9_pg@8.8.0+ts-node@10.9.1
uuid: 8.3.2 uuid: 8.3.2
devDependencies: devDependencies:
'@nestjs/cli': 9.1.1 '@nestjs/cli': 9.1.1
@@ -2338,7 +2338,7 @@ packages:
rxjs: 7.5.6 rxjs: 7.5.6
dev: false dev: false
/@nestjs/typeorm/9.0.1_st2lgrtczmd47ypuvaupbfaph4: /@nestjs/typeorm/9.0.1_tq7xycdignr3g27t42km5o6vju:
resolution: {integrity: sha512-A2BgLIPsMtmMI0bPKEf4bmzgFPsnvHqNBx3KkvaJ7hJrBQy0OqYOb+Rr06ifblKWDWS2tUPNrAFQbZjtk3PI+g==} resolution: {integrity: sha512-A2BgLIPsMtmMI0bPKEf4bmzgFPsnvHqNBx3KkvaJ7hJrBQy0OqYOb+Rr06ifblKWDWS2tUPNrAFQbZjtk3PI+g==}
peerDependencies: peerDependencies:
'@nestjs/common': ^8.0.0 || ^9.0.0 '@nestjs/common': ^8.0.0 || ^9.0.0
@@ -2351,7 +2351,7 @@ packages:
'@nestjs/core': 9.0.11_psficsz3mqirqwo2ujbfhdr2aa '@nestjs/core': 9.0.11_psficsz3mqirqwo2ujbfhdr2aa
reflect-metadata: 0.1.13 reflect-metadata: 0.1.13
rxjs: 7.5.6 rxjs: 7.5.6
typeorm: 0.3.8_pg@8.8.0+ts-node@10.9.1 typeorm: 0.3.9_pg@8.8.0+ts-node@10.9.1
uuid: 8.3.2 uuid: 8.3.2
dev: false dev: false
@@ -9038,8 +9038,8 @@ packages:
/typedarray/0.0.6: /typedarray/0.0.6:
resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==} resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==}
/typeorm/0.3.8_pg@8.8.0+ts-node@10.9.1: /typeorm/0.3.9_pg@8.8.0+ts-node@10.9.1:
resolution: {integrity: sha512-77PNamypfwieZlhwbUAjMudX2T+5F6JCoNR18RdKenJ5Uu+9gc9AWa1kmz/2hH84MU23lGqPCu8u2lKnlfsN2g==} resolution: {integrity: sha512-xNcE44D4hn74n7pjuMog9hRgep+BiO3IBpjEaQZ8fb56zsDz7xHT1GAeWwmGuuU+4nDEELp2mIqgSCR+zxR7Jw==}
engines: {node: '>= 12.9.0'} engines: {node: '>= 12.9.0'}
hasBin: true hasBin: true
peerDependencies: peerDependencies:
+1 -1
View File
@@ -45,7 +45,7 @@
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rxjs": "^7.5.6", "rxjs": "^7.5.6",
"typeorm": "0.3.8", "typeorm": "0.3.9",
"uuid": "^8.3.2" "uuid": "^8.3.2"
}, },
"devDependencies": { "devDependencies": {