Skip to content

Commit

Permalink
add docs and minor file clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkySharks committed Feb 7, 2019
1 parent d04e0d5 commit 7966261
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3,268 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
packages/**/node_modules
packages/**/dist
packages/**/dist
21 changes: 20 additions & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# Docker Directory

This directory stores certificates for local SSL/TLS, created by running `run-docker` script, as well as configuration for docker environment setup.
This directory stores certificates for local SSL/TLS, created by running `run-docker` script, as well as configuration for docker environment setup.

Run the `docker/run-docker` script from the root of the repository to create a container running PWA with a secure https protocol.

This script will:

* copy the `.env.docker` environment variables to `.env` to be easily consumable by `docker-compose`
* add a custom domain, configured in `.env.docker`, to the host system's `/etc/hosts` file
* generate a self-signed ssl/tls certificate and trust the certificate in the system keychain
* run `docker-compose build` to build the container network
* run `docker-compose up` to start the container running PWA at the custom domain with https

After `docker/run-docker` is executed from the root of the repository, the default configuration will have the PWA application running at `https://pwa-docker.local`.

### Configure a new custom domain

The domain is configurable. Two changes are needed to configure a new domain name.

1. Change `PWA_STUDIO_PUBLIC_PATH` key to the new domain in `docker/.env.docker`.
2. Change the `--host` value in the `watch:docker` script in `packages/venia-concept/package.json` to the new domain.
20 changes: 12 additions & 8 deletions docker/run-docker
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,33 @@ main () {
DOMAIN=$PWA_STUDIO_PUBLIC_PATH
HOSTMAP="127.0.0.1 $DOMAIN"

add_host_to_hostfile
add_domain_to_hostfile

generate_certificate

start_docker
}

add_host_to_hostfile () {
if [ "$HOSTMAP" == "127.0.0.1" ]; then
echo "No custom host set to configure."
return
add_domain_to_hostfile () {
# handle if a domain was not configured
if [ "$HOSTMAP" == "127.0.0.1 " ]; then
message "Domain not found.\nPlease provide a custom domain in docker/.env.docker under the key:\nPWA_STUDIO_PUBLIC_PATH"
exit 1
fi


# check to see if the hostfile already contains the hostmap/domain
while read -r var; do
if [ "$var" == "$HOSTMAP" ]; then
HOSTPRESENT=true
fi
done < $HOSTSFILE

# add the domain if it is not present in the hostfile, otherwise don't
if [ $HOSTPRESENT == false ]; then
message "Please provide your password, if requested, to modify $HOSTSFILE"
echo $HOSTMAP | sudo tee -a $HOSTSFILE

# handle error with adding to the hostfile
if [ $? == 0 ]; then
message "Added $HOSTMAP configured in $ENVFILE to $HOSTSFILE"
else
Expand Down Expand Up @@ -95,7 +99,7 @@ EOL
-out ./docker/certs/$DOMAIN.crt \
-config $OpenSSLConf

# add the certificate to the System keychain and trust the certificate
# add the certificate to the system keychain and trust the certificate
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ./docker/certs/$DOMAIN.crt

if [ $? == 0 ]; then
Expand Down Expand Up @@ -129,4 +133,4 @@ message () {
echo ""
}

main
main
5 changes: 0 additions & 5 deletions packages/venia-concept/.env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ UPWARD_JS_LOG_URL=1
# Set this to 1 (true) to force ServiceWorkers in development.
# ENABLE_SERVICE_WORKER_DEBUGGING=1
#
# Set own port for development.
# PWA_STUDIO_PORTS_DEVELOPMENT=8080
#
# To run on localhost:8080, for instance,
# set MAGENTO_BUILDPACK_PROVIDE_SECURE_HOST=0 above and PWA_STUDIO_PORTS_DEVELOPMENT=8080
###############################################################################

########## Braintree integration configuration ######################
Expand Down
Loading

0 comments on commit 7966261

Please sign in to comment.