[docker] Add workdir attribute

The workdir attribute set the initial working directory
when starting the docker container.

Contrary to the WORKDIR directive (see
https://docs.docker.com/reference/builder/#workdir), it only affects
the entry point.

--
MOS_MIGRATED_REVID=104201472
diff --git a/tools/build_defs/docker/rewrite_json_test.py b/tools/build_defs/docker/rewrite_json_test.py
index 80400e7..3d89d1d 100644
--- a/tools/build_defs/docker/rewrite_json_test.py
+++ b/tools/build_defs/docker/rewrite_json_test.py
@@ -646,5 +646,35 @@
         name=name, parent=parent, volumes=[volume]))
     self.assertEquals(expected, actual)
 
+  def testSetWorkingDir(self):
+    in_data = {
+        'config': {
+            'User': 'bleh',
+            'WorkingDir': '/home/bleh',
+            'Volumes': {
+            }
+        }
+    }
+    name = 'deadbeef'
+    parent = 'blah'
+    workdir = '/some/path'
+    expected = {
+        'id': name,
+        'parent': parent,
+        'config': {
+            'User': 'bleh',
+            'WorkingDir': '/some/path',
+            'Volumes': {
+            }
+        },
+        'docker_version': _DOCKER_VERSION,
+        'architecture': _PROCESSOR_ARCHITECTURE,
+        'os': _OPERATING_SYSTEM,
+    }
+
+    actual = RewriteMetadata(in_data, MetadataOptions(
+        name=name, parent=parent, workdir=workdir))
+    self.assertEquals(expected, actual)
+
 if __name__ == '__main__':
   unittest.main()