Skip to content

Commit e8c1db2

Browse files
Merge pull request #27 from oslabs-beta/mike/ecr
Mike/ecr
2 parents 2496eb0 + c3190c7 commit e8c1db2

26 files changed

+478
-238
lines changed

.Dockerfile-1stage

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM node:19-alpine
2+
3+
#python: required dependency for node alpine, shrinks image size from 2.17GB to 1.67GB
4+
RUN apk add --no-cache --virtual .gyp \
5+
python3 \
6+
make \
7+
g++
8+
9+
WORKDIR /app
10+
11+
COPY package*.json ./
12+
13+
COPY app/dist /app
14+
15+
# COPY .env .env
16+
17+
COPY server ./server
18+
19+
COPY config.js ./config.js
20+
21+
RUN npm install --no-install-recommends
22+
23+
EXPOSE 5656
24+
25+
ENV IS_DOCKER true
26+
27+
CMD [ "npm", "start" ]
28+
29+
# create docker image: "docker build -t reactype-container ." Note: if you want reactype-container with a different name (must be all lowercase)
30+
# run docker container: "docker run -d -p 5656:5656 reactype-container" docker run -d -p 5656:5656 reactype-v15
31+
# comment out window.api.formatCode(), but will break it for electron app.

.Dockerfile-nginx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Stage 1: Build
2+
FROM node:19-alpine as build
3+
4+
# python: required dependency for node alpine, shrinks image size from 2.17GB to 1.67GB
5+
RUN apk add --no-cache --virtual .gyp \
6+
python3 \
7+
make \
8+
g++
9+
10+
WORKDIR /app
11+
12+
COPY package*.json ./
13+
14+
RUN npm install --no-install-recommends
15+
16+
COPY . .
17+
18+
# Stage 2: Node Server
19+
FROM node:19-alpine as node_server
20+
21+
WORKDIR /app
22+
23+
COPY --from=build /app/package*.json ./
24+
25+
RUN npm install --no-install-recommends --only=production
26+
27+
COPY --from=build /app/.env .env
28+
COPY --from=build /app/config.js ./config.js
29+
COPY --from=build /app/server ./server
30+
31+
EXPOSE 5656
32+
33+
ENV IS_DOCKER true
34+
35+
CMD [ "npm", "start" ]
36+
37+
# Stage 3: Nginx Server
38+
FROM nginx:alpine as nginx_server
39+
40+
# Copy the build output to the Nginx html directory
41+
COPY --from=build /app/app/dist /usr/share/nginx/html
42+
43+
# Copy the Nginx configuration file
44+
COPY nginx.conf /etc/nginx/conf.d/default.conf
45+
46+
EXPOSE 80
47+
48+
CMD ["nginx", "-g", "daemon off;"]

.docker-compose-nginx.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: '3'
2+
3+
services:
4+
web:
5+
build:
6+
context: .
7+
target: nginx_server
8+
ports:
9+
- '80:80'
10+
api:
11+
build:
12+
context: .
13+
target: node_server
14+
ports:
15+
- '5656:5656'

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
app/electron

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ dist/
8787
build/
8888
release-builds/
8989

90+
# .docker-compose-nginx.yml
91+
# .Dockerfile-1stage
92+
# .Dockerfile-nginx
93+
# .electron
94+
9095
# TypeScript v1 declaration files
9196
typings/
9297

@@ -496,4 +501,6 @@ server/rootCA.key
496501
server/rootCA.pem
497502
server/RootCA.srl
498503

504+
505+
499506
# End of https://www.gitignore.io/api/node,linux,macos,windows,visualstudio,yarn

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Stage 1: Build
2+
FROM node:19-alpine as build
3+
4+
# python: required dependency for node alpine, shrinks image size from 2.17GB to 1.67GB
5+
RUN apk add --no-cache --virtual .gyp \
6+
python3 \
7+
make \
8+
g++
9+
10+
WORKDIR /app
11+
12+
COPY package*.json ./
13+
14+
RUN npm install --no-install-recommends --fetch-retry-maxtimeout 500000
15+
16+
COPY . .
17+
18+
# Stage 2: Runtime
19+
FROM node:19-alpine as runtime
20+
21+
WORKDIR /app
22+
23+
COPY --from=build /app/package*.json ./
24+
25+
RUN npm install --no-install-recommends --only=production --fetch-retry-maxtimeout 500000
26+
27+
# COPY --from=build /app/.env .env
28+
COPY --from=build /app/config.js ./config.js
29+
COPY --from=build /app/server ./server
30+
COPY --from=build /app/app/dist /app
31+
32+
EXPOSE 5656
33+
34+
ENV IS_DOCKER true
35+
36+
CMD [ "npm", "start" ]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

app/src/components/login/SignIn.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ const SignIn: React.FC<LoginInt & RouteComponentProps> = props => {
171171
) => {
172172
e.preventDefault();
173173
// window.api.github();
174-
window.location.assign('http://localhost:5656/auth/github');
174+
// 8080 for container 5656 for dev
175+
window.location.assign('http://localhost:5656/auth/github')
175176
}
176177
const responseFacebook = response => {
177178
if (response.accessToken) {
@@ -303,7 +304,7 @@ const SignIn: React.FC<LoginInt & RouteComponentProps> = props => {
303304
id="SignInWithGoogle"
304305
onClick={(e)=>{
305306
e.preventDefault();
306-
window.location.assign('http://localhost:5656/auth/google');
307+
window.location.assign('http://localhost:5656/auth/google')
307308
}}
308309
sx={{
309310
marginBottom: '5px'

app/src/components/right/LoginButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export default function LoginButton() {
1111
const handleLogout = () => {
1212
window.localStorage.clear();
1313
if (process.env.NODE_ENV === 'production') {
14-
window.api.delCookie();
15-
window.location.href = '/index-prod.html'
14+
document.cookie = 'ssid' + '=; Max-Age=0'
15+
window.location.href = 'http://localhost:5656/'
1616
} else {
1717
window.location.href = 'http://localhost:8080/#/login';
1818
if(state.isLoggedIn){

0 commit comments

Comments
 (0)