Skip to content

Commit

Permalink
fix dockerfile env
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelebarre committed Oct 28, 2024
1 parent ad7bc06 commit faace9f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ services:
build:
context: ./frontend
args:
VITE_API_URL: http://backend
VITE_API_PORT: 8080
TUTO_API_URL: http://backend
TUTO_API_PORT: 8080
image: pdelebarre/guitar-tutorial-app-frontend

ports:
Expand Down
3 changes: 0 additions & 3 deletions frontend/.env

This file was deleted.

3 changes: 3 additions & 0 deletions frontend/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VITE_API_URL=http://localhost
VITE_API_PORT=8080
VITE_ENVIRONMENT=DEVELOPMENT
3 changes: 3 additions & 0 deletions frontend/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VITE_API_URL=TUTO_API_URL
VITE_API_PORT=TUTO_API_PORT
VITE_ENVIRONMENT=PRODUCTION
12 changes: 3 additions & 9 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ FROM node:18-alpine AS builder
# Set the working directory inside the container
WORKDIR /app

# Define build args
ARG VITE_API_URL
ENV VITE_API_URL=${VITE_API_URL}
ARG VITE_API_PORT
ENV VITE_API_PORT=${VITE_API_PORT}

COPY .env .
# COPY .env .
# Copy package.json and package-lock.json
COPY package*.json ./

Expand All @@ -31,8 +25,8 @@ COPY --from=builder /app/dist /usr/share/nginx/html

#shell to be able to catch variables at docker run time
#https://dev.to/sanjayttg/dynamic-environment-variables-for-dockerized-react-apps-5bc5
# COPY env.sh /docker-entrypoint.d/env.sh
# RUN chmod +x /docker-entrypoint.d/env.sh
COPY env.sh /docker-entrypoint.d/env.sh
RUN chmod +x /docker-entrypoint.d/env.sh


# Expose the port NGINX is running on
Expand Down

0 comments on commit faace9f

Please sign in to comment.