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

View File

@ -1,3 +1,6 @@
# Android App
/app
# Build Artifacts
dist
.next
@ -22,6 +25,3 @@ node_modules
Dockerfile
.dockerignore
docker-compose.yml
# Android App
/app

View File

@ -4,8 +4,8 @@ TURBO_TOKEN=
# Server + Client
TZ=UTC
PUBLIC_URL=http://client:3000
PUBLIC_SERVER_URL=http://server:3100
PUBLIC_URL=http://localhost:3000
PUBLIC_SERVER_URL=http://localhost:3100
PUBLIC_GOOGLE_CLIENT_ID=
# Server + Database

View File

@ -15,19 +15,6 @@ const nextConfig = {
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
// Ref: https://github.com/tailwindlabs/tailwindcss/issues/3258#issuecomment-968368156
webpack: (config) => {

View File

@ -18,46 +18,44 @@ import queryClient from '@/services/react-query';
import store, { persistor } from '@/store/index';
import WrapperRegistry from '@/wrappers/index';
const App: React.FC<AppProps> = ({ Component, pageProps }) => {
return (
<>
<Head>
<title>Reactive Resume</title>
const App: React.FC<AppProps> = ({ Component, pageProps }) => (
<>
<Head>
<title>Reactive Resume</title>
<meta
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."
/>
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="initial-scale=1, width=device-width" />
</Head>
<meta
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."
/>
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="initial-scale=1, width=device-width" />
</Head>
<ReduxProvider store={store}>
<LocalizationProvider dateAdapter={DayjsAdapter}>
<PersistGate loading={null} persistor={persistor}>
<GoogleOAuthProvider clientId={env('GOOGLE_CLIENT_ID')}>
<QueryClientProvider client={queryClient}>
<WrapperRegistry>
<Loading />
<ReduxProvider store={store}>
<LocalizationProvider dateAdapter={DayjsAdapter}>
<PersistGate loading={null} persistor={persistor}>
<GoogleOAuthProvider clientId={env('GOOGLE_CLIENT_ID')}>
<QueryClientProvider client={queryClient}>
<WrapperRegistry>
<Loading />
<Component {...pageProps} />
<Component {...pageProps} />
<ModalWrapper />
<Toaster
position="bottom-right"
toastOptions={{
duration: 4000,
className: 'toast',
}}
/>
</WrapperRegistry>
</QueryClientProvider>
</GoogleOAuthProvider>
</PersistGate>
</LocalizationProvider>
</ReduxProvider>
</>
);
};
<ModalWrapper />
<Toaster
position="bottom-right"
toastOptions={{
duration: 4000,
className: 'toast',
}}
/>
</WrapperRegistry>
</QueryClientProvider>
</GoogleOAuthProvider>
</PersistGate>
</LocalizationProvider>
</ReduxProvider>
</>
);
export default appWithTranslation(App);

View File

@ -1,3 +1,4 @@
import env from '@beam-australia/react-env';
import _axios from 'axios';
import Router from 'next/router';
@ -6,13 +7,14 @@ import { logout } from '@/store/auth/authSlice';
import store from '../store';
export type ServerError = {
statusCode: number;
path: string;
message: 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) => {
const { accessToken } = store.getState().auth;

View File

@ -1,6 +1,5 @@
import env from '@beam-australia/react-env';
import { Resume } from '@reactive-resume/schema';
import _axios, { AxiosResponse } from 'axios';
import { AxiosResponse } from 'axios';
import isBrowser from '@/utils/isBrowser';
@ -63,12 +62,9 @@ export const fetchResumeByIdentifier = async ({
options = { secretKey: '' },
}: FetchResumeByIdentifierParams) => {
if (!isBrowser) {
const serverUrl = env('SERVER_URL');
const secretKey = options.secretKey;
return _axios
.get<Resume>(`${serverUrl}/resume/${username}/${slug}`, { params: { secretKey } })
.then((res) => res.data);
return axios.get<Resume>(`/resume/${username}/${slug}`, { params: { secretKey } }).then((res) => res.data);
}
return axios.get<Resume>(`/resume/${username}/${slug}`).then((res) => res.data);

View File

@ -1,68 +1,79 @@
version: '3.8'
version: "3.8"
services:
postgres:
image: postgres:alpine
container_name: postgres
restart: always
ports:
- 5432:5432
env_file: .env.docker
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
test: ["CMD-SHELL", "pg_isready -U postgres"]
start_period: 15s
interval: 30s
timeout: 30s
retries: 3
restart: always
traefik:
image: traefik:latest
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
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
server:
# image: amruthpillai/reactive-resume:server-latest
build:
context: .
dockerfile: ./server/Dockerfile
image: amruthpillai/reactive-resume:server-latest
# build:
# context: .
# dockerfile: ./server/Dockerfile
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
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:
# image: amruthpillai/reactive-resume:client-latest
build:
context: .
dockerfile: ./client/Dockerfile
image: amruthpillai/reactive-resume:client-latest
# build:
# context: .
# dockerfile: ./client/Dockerfile
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
ports:
- 3000:3000
depends_on:
- server
environment:
- PUBLIC_URL=http://localhost:3000
- PUBLIC_SERVER_URL=http://localhost:3100
- PUBLIC_GOOGLE_CLIENT_ID=
volumes:
pgdata:

View File

@ -1,6 +1,6 @@
{
"name": "reactive-resume",
"version": "3.6.3",
"version": "3.6.4",
"private": true,
"scripts": {
"dev": "env-cmd --silent turbo run dev",

14
pnpm-lock.yaml generated
View File

@ -240,7 +240,7 @@ importers:
ts-loader: ^9.3.1
ts-node: ^10.9.1
tsconfig-paths: ^4.1.0
typeorm: 0.3.8
typeorm: 0.3.9
typescript: ^4.8.2
uuid: ^8.3.2
webpack: ^5.74.0
@ -257,7 +257,7 @@ importers:
'@nestjs/schedule': 2.1.0_fvppslgepxggj3fnmtlnh4cori
'@nestjs/serve-static': 3.0.0_khr6mt6ojlxbw7bo55fknouh34
'@nestjs/terminus': 9.1.1_mr622mjrz7hsw5sxbt7k6brday
'@nestjs/typeorm': 9.0.1_st2lgrtczmd47ypuvaupbfaph4
'@nestjs/typeorm': 9.0.1_tq7xycdignr3g27t42km5o6vju
'@types/passport': 1.0.10
bcryptjs: 2.4.3
cache-manager: 4.1.0
@ -282,7 +282,7 @@ importers:
reflect-metadata: 0.1.13
rimraf: 3.0.2
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
devDependencies:
'@nestjs/cli': 9.1.1
@ -2338,7 +2338,7 @@ packages:
rxjs: 7.5.6
dev: false
/@nestjs/typeorm/9.0.1_st2lgrtczmd47ypuvaupbfaph4:
/@nestjs/typeorm/9.0.1_tq7xycdignr3g27t42km5o6vju:
resolution: {integrity: sha512-A2BgLIPsMtmMI0bPKEf4bmzgFPsnvHqNBx3KkvaJ7hJrBQy0OqYOb+Rr06ifblKWDWS2tUPNrAFQbZjtk3PI+g==}
peerDependencies:
'@nestjs/common': ^8.0.0 || ^9.0.0
@ -2351,7 +2351,7 @@ packages:
'@nestjs/core': 9.0.11_psficsz3mqirqwo2ujbfhdr2aa
reflect-metadata: 0.1.13
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
dev: false
@ -9038,8 +9038,8 @@ packages:
/typedarray/0.0.6:
resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==}
/typeorm/0.3.8_pg@8.8.0+ts-node@10.9.1:
resolution: {integrity: sha512-77PNamypfwieZlhwbUAjMudX2T+5F6JCoNR18RdKenJ5Uu+9gc9AWa1kmz/2hH84MU23lGqPCu8u2lKnlfsN2g==}
/typeorm/0.3.9_pg@8.8.0+ts-node@10.9.1:
resolution: {integrity: sha512-xNcE44D4hn74n7pjuMog9hRgep+BiO3IBpjEaQZ8fb56zsDz7xHT1GAeWwmGuuU+4nDEELp2mIqgSCR+zxR7Jw==}
engines: {node: '>= 12.9.0'}
hasBin: true
peerDependencies:

View File

@ -45,7 +45,7 @@
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.5.6",
"typeorm": "0.3.8",
"typeorm": "0.3.9",
"uuid": "^8.3.2"
},
"devDependencies": {