Skip to content

Commit

Permalink
fix: docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
ddecrulle committed Jul 25, 2023
1 parent 20142b4 commit 427e14a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
29 changes: 16 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,37 @@ COPY package.json yarn.lock .env ./
COPY public ./public
RUN yarn install --frozen-lockfile --network-timeout 600000
COPY jsconfig.json .prettierrc ./
COPY scripts ./scripts
COPY src ./src
RUN yarn build
COPY nginx.conf ./

# Production Env
FROM nginx:stable-alpine

COPY --from=build /app/nginx.conf /etc/nginx/conf.d/default.conf
WORKDIR /usr/share/nginx
WORKDIR /usr/share/nginx/html


# Add bash
RUN apk add --no-cache bash

## Copy .env file and shell script to container
COPY ./scripts/env.sh .
COPY ./scripts/.env .
COPY --from=build /app/build ./
COPY --from=build /app/scripts/env.sh .
COPY --from=build /app/scripts/.env .

COPY --from=build /app/build ./html

## Make shell script executable and prevent windows encoding
RUN sed -i -e 's/\r$//' env.sh && sed -i -e 's/\r$//' .env && chmod +x env.sh

RUN sed -i.orig -e '/user[[:space:]]\+nginx/d' -e 's@pid[[:space:]]\+.*@pid /tmp/nginx.pid;@' /etc/nginx/nginx.conf && \
diff -u /etc/nginx/nginx.conf.orig /etc/nginx/nginx.conf ||: && \
chown nginx /usr/share/nginx/html/index.html && \
chown -Rc nginx /var/cache/nginx
# Equivalent to 'USER nginx', see: https://github.com/InseeFrLab/onyxia-web/pull/279
USER 101
# add non-root user
RUN touch /var/run/nginx.pid
RUN chown -R nginx:nginx /var/run/nginx.pid /usr/share/nginx/html /var/cache/nginx /var/log/nginx /etc/nginx/conf.d

## non root users cannot listen on 80
# non root users cannot listen on 80
EXPOSE 8080

USER nginx

# Start Nginx server
CMD ["/bin/bash", "-c", "/usr/share/nginx/html/env.sh && nginx -g \"daemon off;\""]
ENTRYPOINT bash -c "/usr/share/nginx/html/env.sh && nginx -g 'daemon off;'"
2 changes: 1 addition & 1 deletion nginx.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server {
listen 80 default_server;
listen 8080;
server_name /usr/share/nginx/html;

root /usr/share/nginx/html;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "platine-management",
"version": "0.2.11",
"version": "0.2.12",
"private": true,
"dependencies": {
"@emotion/react": "^11.11.1",
Expand Down
2 changes: 1 addition & 1 deletion scripts/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ do

done < .env
envsubst < "./configuration.json" > "configuration.temp"
envsubst < "./keycloak.json" > "keycloak.temp"
envsubst < "./keycloak.json" > "keycloak.temp"
mv configuration.temp configuration.json
mv keycloak.temp keycloak.json

0 comments on commit 427e14a

Please sign in to comment.