Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0cb4570
gid and uid not working (bind volume override ownership)
ggjulio Jan 29, 2022
534afdd
cant resolve it
ggjulio Jan 29, 2022
b9f85f1
.
ggjulio Jan 30, 2022
89baecf
.
ggjulio Jan 30, 2022
a527264
.
ggjulio Jan 30, 2022
86f5f10
.
ggjulio Jan 30, 2022
9bb92f7
i hate docker at school
ggjulio Feb 4, 2022
ce95bef
upd readme
ggjulio Feb 4, 2022
3fa8c85
working at school
ggjulio Feb 4, 2022
bf65e11
fix dockerfile
ggjulio Feb 4, 2022
53bbd19
change dockerfile 'from: node:16-alpine3.14 -> node:16-alpine3.15
ggjulio Feb 4, 2022
9bfc67c
Merge remote-tracking branch 'upstream/main' into docker_linux_school
ggjulio Feb 4, 2022
fb5def0
Merge remote-tracking branch 'upstream/main' into docker_linux_school
ggjulio Feb 6, 2022
d8c018a
Merge remote-tracking branch 'upstream/main' into docker_linux_school
ggjulio Mar 23, 2022
c566563
.
ggjulio Mar 23, 2022
6590e84
seem to work in 42 local network
ggjulio Mar 23, 2022
3770369
Merge remote-tracking branch 'upstream/main' into docker_linux_school
ggjulio Mar 23, 2022
d12830c
Merge remote-tracking branch 'upstream/main' into docker_linux_school
ggjulio Mar 24, 2022
33c8466
to try at school
ggjulio Mar 24, 2022
495058c
.
ggjulio Mar 24, 2022
701c2d8
.
ggjulio Mar 24, 2022
d809dd6
Merge remote-tracking branch 'upstream/main' into docker_linux_school
ggjulio Mar 24, 2022
2b02b0e
Merge remote-tracking branch 'upstream/main' into docker_linux_school
ggjulio Mar 24, 2022
7ea1a83
Merge remote-tracking branch 'upstream/main' into docker_linux_school
ggjulio Mar 25, 2022
83011cc
Merge remote-tracking branch 'upstream/main' into docker_linux_school
ggjulio Mar 25, 2022
1e2a0d5
Merge remote-tracking branch 'upstream/main' into docker_linux_school
ggjulio Mar 25, 2022
e4d6a07
rm refresh token
ggjulio Mar 25, 2022
fa9262b
Merge remote-tracking branch 'upstream/main' into docker_linux_school
ggjulio Mar 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
./**
# Ignore everything
./**

# Whitelist
!./docker-entrypoint.sh
22 changes: 19 additions & 3 deletions Dockerfile.42-node
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
FROM node:16-alpine3.14
FROM node:16-alpine3.15

RUN apk add --no-cache curl zsh git emacs vim;
RUN apk add --no-cache su-exec curl zsh git emacs vim;

# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#global-npm-dependencies
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin

# node:node is 1000:1000 so good for us
# set up specific uid and gid : https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#non-root-user
ARG HOST_UID=1000
ARG HOST_GID=1000

RUN deluser --remove-home node \
&& addgroup -S node -g $HOST_GID \
&& adduser -u $HOST_UID -G node -SD -s /bin/sh node \
&& mkdir -p /app \
&& chown -R node:node /app

USER node

ARG OH_MY_ZSH_THEME=cloud
Expand All @@ -18,6 +27,13 @@ RUN set -eux; \
@vue/cli@next \
typeorm-cli;


VOLUME /app
WORKDIR /app

USER root

COPY docker-entrypoint.sh /usr/local/bin
ENTRYPOINT ["docker-entrypoint.sh"]

CMD [ "zsh" ]
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@ git clone https://github.com/Working-From-Home/ft_transcendence.git && cd ft_tra
Create a `.env` file, template example:
```
ACCESS_TOKEN_SECRET=my_secret
REFRESH_TOKEN_SECRET=my_secret2
# expressed in seconds or a string describing a time span zeit/ms. Eg: 60, "2 days", "10h", "7d"
ACCESS_TOKEN_EXPIRATION=3200s
REFRESH_TOKEN_EXPIRATION=15d

ACCESS_TOKEN_EXPIRATION=7d

# Must change thoses two variables BEFORE BUILD AND RUN if
# running on 42's linux dump.
# Type the command `id` to get your `uid` and `gid`)
# Also it only works ouside `NFS`, like `/goinfre` or `/tmp`,
# thus, it doesn't works inside `/sgoinfre`, or your home `~/`.
# (PS: pretty useless because docker rootless set "random" uid:gid)
HOST_UID=1000
HOST_GID=1000

HOSTNAME=e2r10p17
FRONTEND_PORT=8080
# localhost can be replaced by the hostname or ip of the computer to
# make the website available from others computers.
# example: http://e2r5p13:3000 or http://10.05.155.14:3000
Expand Down
26 changes: 16 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
version: "3.8"
version: "3.3"
services:
frontend:
restart: always
image: 42-node
build:
context: ./
dockerfile: Dockerfile.42-node
args:
- HOST_UID=${HOST_UID-1000}
- HOST_GID=${HOST_GID-1000}
volumes:
- ./frontend/:/app
- ./shared/:/shared
environment:
- NODE_ENV=${NODE_ENV-development}
- VUE_APP_BACKEND_SERVER_URI=${BACKEND_SERVER_URI}
- VUE_APP_HOSTNAME=${HOSTNAME}
- VUE_APP_FRONTEND_PORT=${FRONTEND_PORT}
ports:
- 8080:8080
- ${FRONTEND_PORT}:${FRONTEND_PORT}
networks:
- mynet
# - mynet
mynet:
aliases:
- ${HOSTNAME}
command: sh -c 'npm install && npm run serve'

backend:
Expand All @@ -26,8 +34,6 @@ services:
environment:
- ACCESS_TOKEN_SECRET=${ACCESS_TOKEN_SECRET}
- ACCESS_TOKEN_EXPIRATION=${ACCESS_TOKEN_EXPIRATION}
- REFRESH_TOKEN_SECRET=${REFRESH_TOKEN_SECRET}
- REFRESH_TOKEN_EXPIRATION=${REFRESH_TOKEN_EXPIRATION}
- BACKEND_SERVER_URI=${BACKEND_SERVER_URI}
- OAUTH_REDIRECT_URI=${OAUTH_REDIRECT_URI}
- FORTY_TWO_CLIENT_ID=${FORTY_TWO_CLIENT_ID}
Expand All @@ -50,10 +56,10 @@ services:
- 3000:3000
- 9229:9229
networks:
- mynet
# mynet:
# aliases:
# - ${DOMAIN}
# - mynet
mynet:
aliases:
- ${HOSTNAME}
# command: sh -c 'npm install && npm run start:dev'
command: sh -c 'npm install && npm run start:debug'

Expand All @@ -65,7 +71,7 @@ services:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- PGPORT= ${POSTGRES_PORT}
ports:
- 5432:${POSTGRES_PORT}
- 5454:${POSTGRES_PORT} # default postgres (5432) port already in use in school's linux dump
networks:
- mynet
volumes:
Expand Down
30 changes: 30 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

set -x

BOLD="\e[1m"
RESET="\e[0m"
LIGHT_RED="\e[91m"
LIGHT_GREEN="\e[92m"
LIGHT_CYAN="\e[96m"

logging(){
local type=$1; shift
printf "${LIGHT_CYAN}${BOLD}Entrypoint${RESET} [%b] : %b\n" "$type" "$*"
}
log_info(){
logging "${LIGHT_GREEN}info${RESET}" "$@"
}
log_error(){
logging "${LIGHT_RED}error${RESET}" "$@" >&2
exit 1
}

log_info "Entrypoint script started..."
if [ "$(id -u)" = "0" ]; then
log_info "Switch from root:root to node:node, aka $(id -u node):$(id -g node) "
chown -R node:node /app
exec su-exec node "$0" "$@"
fi

exec "$@"
6 changes: 5 additions & 1 deletion frontend/vue.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
devServer: {
host: process.env.VUE_APP_HOSTNAME,
port: process.env.VUE_APP_FRONTEND_PORT,
},
css: {
loaderOptions: {
sass: {
Expand All @@ -11,4 +15,4 @@ module.exports = {
},
},
},
};
};
2 changes: 1 addition & 1 deletion frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ module.exports = {
},
},
},
};
};