Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
uses: actions/checkout@v4
- name: Update Hosts file
run: sudo sed -i '/^127.0.0.1/ s/$/ test.localhost/' /etc/hosts
- run: docker-compose up -d
- run: docker-compose -f tests/docker-compose.yml up -d
- run: docker compose up -d
- run: docker compose -f tests/docker-compose.yml up -d
- run: sleep 1
- run: curl --fail --output test.html http://test.localhost
- run: grep 'Hello world!' test.html
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
The Docker Compose file in this repository contains an instance of
[Traefik](https://traefik.io/) for development purposes. It allows you to access
microservices through your browser using a hostname (such as
`accounts.leviy.localhost`) and to run multiple microservices at the same time
`accounts.leviy.test`) and to run multiple microservices at the same time
without port binding conflicts.

## Getting started
Expand All @@ -16,14 +16,14 @@ without port binding conflicts.

- [Docker](https://docs.docker.com/install/)
- [Docker Compose](https://docs.docker.com/compose/)
- A DNS resolver that resolves any hostname ending in ".localhost" to 127.0.0.1 (see [instructions](docs/dns.md))
- A DNS resolver that resolves any hostname ending in ".test" to 127.0.0.1 (see [instructions](docs/dns.md))

### Installation

```bash
git clone git@github.com:leviy/workspace.git
cd workspace
docker-compose up -d
docker compose up -d
```

The Docker Compose file contains the `restart: always` directive so Docker will
Expand All @@ -32,7 +32,7 @@ need to start another container or project that needs to bind to port 80, you
can stop the containers using:

```bash
docker-compose stop
docker compose stop
```

### Usage
Expand All @@ -51,7 +51,7 @@ services:
- workspace
- default
labels:
traefik.frontend.rule: Host:subdomain.leviy.localhost
traefik.frontend.rule: Host:subdomain.leviy.test
traefik.enable: 'true'

networks:
Expand All @@ -67,5 +67,5 @@ Non-web services (such as databases, etc.) should only be linked to the

When started, Traefik will automatically detect this service and start routing
traffic to it.
To see it in action simply open `http://subdomain.leviy.localhost` in a
To see it in action simply open `http://subdomain.leviy.test` in a
browser.
40 changes: 7 additions & 33 deletions docs/dns.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,15 @@ host you need to configure your DNS to resolve all hostnames ending on

## Linux (Ubuntu)

On Ubuntu 18.04 no action is required, because [systemd-resolved](https://manpages.ubuntu.com/manpages/bionic/man8/systemd-resolved.service.8.html)
already resolves hostnames ending on ".localhost" to 127.0.0.1 and ::1.
On Ubuntu 20.04 you have to manually add lines to the /etc/hosts file for all domains that
you want to resolve locally:

If for some reason resolving is not working on Ubuntu, make sure that the
symlink `/etc/resolv.conf` is pointing to `/run/systemd/resolve/stub-resolv.conf`:

```bash
ll /etc/resolv.conf
```

If this doesn't point to `/run/systemd/resolve/stub-resolv.conf`, overwrite the
symbolic link:

```bash
sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
127.0.0.1 dashboard.leviy.test
127.0.0.1 files.leviy.test
127.0.0.1 accounts.leviy.test
```

## macOS High Sierra

On macOS the same can be achieved by installing dnsmasq and configuring it to
route all traffic for ".localhost" to 127.0.0.1:

```bash
brew install dnsmasq

mkdir -pv $(brew --prefix)/etc/
echo 'address=/.localhost/127.0.0.1' >> $(brew --prefix)/etc/dnsmasq.conf
echo 'port=53' >> $(brew --prefix)/etc/dnsmasq.conf

sudo brew services start dnsmasq

sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/localhost'

ping dashboard.leviy.localhost
```
On Ubuntu 24.04 you can use the `systemd-resolve` to resolve all domains ending on ".test" to 127.0.0.1.

[Source](https://medium.com/@kharysharpe/automatic-local-domains-setting-up-dnsmasq-for-macos-high-sierra-using-homebrew-caf767157e43)
(work in progress, will add additional instructions as soon as we updated to Ubuntu 24.04)