Skip to content

docker-compose #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 13 additions & 2 deletions dockerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
##### Stage 1

FROM node:10.15.0 as builder
FROM node:14.17 as builder

WORKDIR /app

Expand All @@ -24,13 +24,24 @@ ENV ENVIRONMENT=production1
ENV SomeAPIKey="This is not an API Key"
ENV SomeOtherAPIKey="This is not another API Key"

#ARG ENVIRONMENT
#ENV ENVIRONMENT=$ENVIRONMENT
#
#ARG SomeAPIKey
#ENV SomeAPIKey=$SomeAPIKey
#
#ARG SomeOtherAPIKey
#ENV SomeOtherAPIKey=$SomeOtherAPIKey

#RUN echo "Environment: ${ENVIRONMENT} SomeAPIKey: ${SomeAPIKey} SomeOtherAPIKey: ${SomeOtherAPIKey}"

# Build Angular Application in Production
RUN ng build --prod

#### STAGE 2
#### Deploying the application

FROM nginx:alpine
FROM nginx

VOLUME /var/cache/nginx

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ To run this demo,
`git clone https://github.com/coding-latte/using-angular-docker-environment-variables.git`

2. And then, build the docker image:
`docker build --rm -f "dockerfile" -t angular-docker-environment-variables:latest .`
`docker build --rm -f "Dockerfile" -t angular-docker-environment-variables:latest .`

3. And finally run the image you just built:
`docker build --rm -f "dockerfile" -t angular-docker-environment-variables:latest .`
`docker run -d --name angular-docker -p 8085:80 -e SomeAPIKey="ble" angular-docker-environment-variables:latest`

You can learn more about this [here](https://codinglatte.com/posts/angular/using-os-environment-variables-in-angular-with-docker/)
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "3.8"

services:
angular-docker:
image: using-angular-docker-environment-variables:latest
container_name: angular-docker
build:
context: .
dockerfile: Dockerfile
environment:
ENVIRONMENT: "blah blah"
SomeAPIKey: "This is not an API Key"
SomeOtherAPIKey: "This is not another API Key"
ports:
- "8085:80"