Skip to content

Commit

Permalink
reformat docker setup to remove traefik dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
AmruthPillai committed Aug 29, 2022
1 parent 2c95dc2 commit d73ee7b
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 118 deletions.
6 changes: 3 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Android App
/app

# Build Artifacts
dist
.next
Expand All @@ -22,6 +25,3 @@ node_modules
Dockerfile
.dockerignore
docker-compose.yml

# Android App
/app
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions client/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
80 changes: 39 additions & 41 deletions client/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>

<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 />

<Component {...pageProps} />

<ModalWrapper />
<Toaster
position="bottom-right"
toastOptions={{
duration: 4000,
className: 'toast',
}}
/>
</WrapperRegistry>
</QueryClientProvider>
</GoogleOAuthProvider>
</PersistGate>
</LocalizationProvider>
</ReduxProvider>
</>
);
};
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>

<ReduxProvider store={store}>
<LocalizationProvider dateAdapter={DayjsAdapter}>
<PersistGate loading={null} persistor={persistor}>
<GoogleOAuthProvider clientId={env('GOOGLE_CLIENT_ID')}>
<QueryClientProvider client={queryClient}>
<WrapperRegistry>
<Loading />

<Component {...pageProps} />

<ModalWrapper />
<Toaster
position="bottom-right"
toastOptions={{
duration: 4000,
className: 'toast',
}}
/>
</WrapperRegistry>
</QueryClientProvider>
</GoogleOAuthProvider>
</PersistGate>
</LocalizationProvider>
</ReduxProvider>
</>
);

export default appWithTranslation(App);
8 changes: 5 additions & 3 deletions client/services/axios.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import env from '@beam-australia/react-env';
import _axios from 'axios';
import Router from 'next/router';

Expand All @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions client/services/resume.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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);
Expand Down
93 changes: 52 additions & 41 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
restart: always
ports:
- 3100:3100
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
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
- [email protected]
- 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
restart: always
ports:
- 3000:3000
depends_on:
- traefik
- server
labels:
- traefik.enable=true
- traefik.http.routers.client.rule=Host(`localhost`)
- traefik.http.routers.client.entrypoints=web
restart: always
environment:
- PUBLIC_URL=http://localhost:3000
- PUBLIC_SERVER_URL=http://localhost:3100
- PUBLIC_GOOGLE_CLIENT_ID=

volumes:
pgdata:
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit d73ee7b

Please sign in to comment.